Method, device, equipment and storage medium for processing refill data
By not releasing data blocks before waiting for refill data in the cache, the problem of wasted cache resources and inaccessibility of old data is solved, improving cache resource utilization and the efficiency of normal refilling of data blocks.
Patent Information
- Application Number
- CN202410053386.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-12
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-01-12
AI Technical Summary
During the cache refill process of the processor, due to the long time required for the lower-level cache to send data to the upper-level cache, the data blocks are released while waiting for the refill data to arrive, causing idleness and waste of cache resources. At the same time, old data cannot be accessed normally.
When the memory access instruction misses, the data block is not released immediately, but the lower-level cache is notified to obtain the refill data. After the data arrives, the target data block is determined from the cache and the old data is released, and the refill data is written into the block. Ensure that the data block has valid data and can be accessed normally during the waiting period.
It improves the utilization of cache resources, ensures that old data can be accessed normally before the arrival of refill data, and realizes the normal refill of data blocks after the arrival of data.
Smart Images

Figure CN117573572B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and computer-readable storage medium for processing refill data. Background Art
[0002] Modern processors generally have three levels of cache: L1 cache, L2 cache and L3 cache. When the processor's memory access instruction misses the L1 cache, L2 cache needs to refill the data requested by the memory access instruction into the L1 cache to ensure normal data access. Similarly, when the memory access instruction misses the L2 cache, L3 cache needs to refill the requested data into the L2 cache.
[0003] Currently, in the process of refilling data from the lower-level cache to the upper-level cache, the upper-level cache first selects a data block (data is used to represent the location where data is stored) and releases the old data in it, and then writes the refill data into the data block when the lower-level cache sends the refill data to realize data refill.
[0004] However, in the above process, it often takes a long time to send the refill data from the lower-level cache to the upper-level cache. During the waiting time for the refill data, the old data in the data block has been released, but the refill data has not yet been received, so there is no valid data in the data block, but the data block is still continuously occupied, resulting in idleness and waste of cache resources. Summary of the invention
[0005] The embodiments of the present application provide a method, device, electronic device and computer-readable storage medium for processing refill data to solve the problems in the related art.
[0006] In a first aspect, an embodiment of the present application provides a method for processing refill data, the method comprising:
[0007] In the case where a memory access instruction of the processor is obtained through the first cache, obtaining a hit result of the memory access instruction in the first cache;
[0008] If the hit result is a miss, the memory access instruction is suspended, and a fetch request is sent to a second cache through the first cache; the second cache is a lower-level cache of the first cache;
[0009] When the first cache receives the refill data sent by the second cache in response to the acquisition request, the target data block is determined from the first cache, the old data stored in the target data block is released, and the refill data is written into the target data block.
[0010] In a second aspect, an embodiment of the present application provides a device for processing refill data, the device comprising:
[0011] An acquisition module, configured to acquire a hit result of a memory access instruction in the first cache when a memory access instruction of the processor is acquired through the first cache;
[0012] a miss module, configured to suspend the memory access instruction if the hit result is a miss, and send a fetch request to a second cache through the first cache; the second cache is a lower-level cache of the first cache;
[0013] A write module is used to determine a target data block from the first cache, release old data stored in the target data block, and write the refill data into the target data block when receiving the refill data sent by the second cache in response to the acquisition request through the first cache.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor;
[0015] a memory for storing instructions executable by the processor;
[0016] The processor is configured to execute the instructions to implement the method of the first aspect.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method of the first aspect.
[0018] In an embodiment of the present application, when a memory access instruction misses in the first cache, the data block is not selected for release first, but the subordinate second cache is notified to obtain the refill data required for the memory access request, and when the second cache obtains the refill data and sends the refill data to the first cache, the target data block is determined from the first cache, and the old data stored in the target data block is released, and the refill data is written into the target data block. In this way, during the period before the arrival of the refill data, the data block storing the old data operates normally, is not vacant or occupied, and the old data can also be accessed normally. In addition, after the first cache receives the refill data, the present application releases the old data stored in the selected target data block, which also ensures the normal implementation of the old data reading process of the memory access instruction during this period.
[0019] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 This is an implementation scenario architecture diagram provided by an embodiment of the present application;
[0022] Figure 2 is a flowchart of a method for processing refill data provided by an embodiment of the present application;
[0023] Figure 3 is a schematic diagram of the architecture of a first cache provided by an embodiment of the present invention;
[0024] Figure 4 It is a flowchart of the specific steps of a method for processing refilling data provided in an embodiment of the present application;
[0025] Figure 5 is a schematic diagram of another architecture of a first cache provided by an embodiment of the present invention;
[0026] Figure 6 This is a block diagram of a data processing device provided by an embodiment of the present application;
[0027] Figure 7 is a block diagram of an electronic device provided by an embodiment of the present invention;
[0028] Figure 8 is a block diagram of another electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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.
[0030] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three kinds of relationships can exist, for example, A and / or B can be represented: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the front and back associated objects are a kind of "or" relationship. In the embodiment of the present application, the term "multiple" refers to two or more, and other quantifiers are similar.
[0031] Reference Figure 1 , Figure 1 This is an implementation scenario architecture diagram provided by the embodiment of the present application. In order to improve execution efficiency and reduce the interaction between the processor and the memory, modern processors can integrate a multi-level cache architecture on the processor. The common architecture is Figure 1 The three-level cache structure includes: Level 1 cache L1, Level 2 cache L2 and Level 3 cache L3. Level 1 cache L1 is the cache closest to the processor, with the smallest capacity and the fastest speed; Level 2 cache L2 has a larger capacity, but is slower than Level 1 cache L1. Level 2 cache L2 is the buffer of Level 1 cache L1. The function of Level 2 cache L2 is to store data that is needed for processor processing but cannot be stored by Level 1 cache L1; Level 3 cache L3 has the largest capacity and is also the slowest level. Level 3 cache L3 and memory can be regarded as buffers of Level 2 cache L2.
[0032] When the processor is running, the processor will first go to the first-level cache L1 to find the required data according to the memory access instruction, then go to the second-level cache L2, and then go to the third-level cache L3. If the third-level cache does not find the data it needs, it will get the data from the memory. The longer the search path, the longer it takes, so if you need to get certain data very frequently, make sure that the data is in the first-level cache L1, so that the speed will be very fast. Among them, the memory access instruction is an instruction to get data from a specified address in the memory, or to store data at a specified address in the memory.
[0033] In the above process, if the memory access instruction does not hit in the first-level cache L1 (meaning that the first-level cache L1 does not store the data requested to be read by the memory access instruction), the memory access instruction will continue to be searched whether it hits in the second-level cache L2. If it hits in the second-level cache L2, the second-level cache L2 will refill the data requested to be read by the memory access instruction into the first-level cache L1; if it does not hit in the second-level cache L2, the memory access instruction will continue to be searched whether it hits in the third-level cache L3. If it hits in the third-level cache L3, the third-level cache L3 will refill the data requested to be read by the memory access instruction into the second-level cache L2, and then the second-level cache L2 will refill the data into the first-level cache L1.
[0034] However, due to the limited cache space, when a cache capacity conflict occurs (i.e., the cache space is full and insufficient to continue storing the refill data), it is necessary to select a data block in the first cache waiting for refilling to release the old data therein, thereby freeing up space to store the refill data.
[0035] The related technology is that when the first cache notifies the lower-level second cache to refill data, it selects a data block in the first cache to release the old data therein, and when the lower-level cache sends the refill data, the refill data is written into the data block to achieve data refill. This will cause the vacant data block to be continuously occupied during the waiting process for the refill data. In addition, if there is a need to access the old data during this process, it cannot be successfully accessed because the old data has been released.
[0036] In order to solve this problem, the embodiment of the present application may not select a data block for release when the memory access instruction does not hit the first cache, but instead notify the subordinate second cache to obtain the refill data required for the memory access request, wait for the second cache to obtain the refill data and send the refill data to the first cache, and then determine the target data block from the first cache, release the old data stored in the target data block, and write the refill data to the target data block. In this way, during the period before the arrival of the refill data, the data block storing the old data operates normally and is not vacant or occupied, and the old data can also be accessed normally. In addition, after the first cache receives the refill data, the present application releases the old data stored in the selected target data block and writes the refill data to the target data block, which also ensures the normal implementation of the old data reading process of the memory access instruction during this period.
[0037] Figure 2 , is a flowchart of a method for processing refill data provided by an embodiment of the present application, such as Figure 2 As shown, the method may include:
[0038] Step 101 : when a memory access instruction of a processor is obtained through a first cache, a hit result of the memory access instruction in the first cache is obtained.
[0039] In an embodiment of the present application, after the memory access instruction enters the pipeline of the first cache, it is necessary to further check whether the first cache contains the data requested to be read by the memory access instruction. The process of determining whether the data exists can be understood as determining the hit result of the memory access instruction in the first cache. The hit result includes a hit or a miss. A hit represents that the first cache contains the data requested to be read by the memory access instruction; a miss represents that the first cache does not contain the data requested to be read by the memory access instruction.
[0040] Specifically, determining the hit result of the memory access instruction in the first cache requires traversing the cache directory of the first cache, so it takes a certain amount of time, which is fixed. Figure 3 , which shows a schematic diagram of the architecture of the first cache. The first cache can adopt a 5-level pipeline architecture, that is, it includes a pipeline queue with 5 sequentially arranged data bits, each data bit corresponds to a pipeline moment, and different data bits correspond to different pipeline moments. The instruction is used to enter the pipeline from the initial data bit S1 of the pipeline queue, and change the data bit with the passage of time. The embodiment of the present application can obtain the hit result of the memory access instruction in the first cache (obtain the hit result at the moment corresponding to the S3 data bit) after the memory access instruction enters the pipeline from the starting data bit (S1) of the pipeline queue, after a fixed number of data bits (for example, an interval of 2 data bits). Since the hit result is obtained, and the hit result includes a hit or a miss. Therefore, the embodiment of the present application can subsequently perform corresponding instruction control operations according to the hit result.
[0041] It should be noted that the fixed number of data bits ( Figure 3 is an interval of 2 data bits), which refers to the time required for the operation of waiting to determine the hit result of the memory access instruction in the first cache. Since the time is fixed, and the data bits in the pipeline queue of the first cache represent the moment, the time can be converted into a fixed number of data bits, starting from the starting data bit (S1), with a fixed number of data bits interval, representing the completion of the execution process of waiting to determine whether a hit is achieved after the memory access instruction enters the pipeline of the first cache, thereby obtaining the hit result of the memory access instruction in the first cache.
[0042] Step 102: If the hit result is a miss, the memory access instruction is suspended, and a fetch request is sent to a second cache through the first cache; the second cache is a lower-level cache of the first cache.
[0043] In an embodiment of the present application, the hit result of the memory access instruction in the first cache is a hit, indicating that the first cache has the data requested to be read by the memory access instruction. If the first cache also has a superior third cache, the first cache can refill the data requested to be read by the memory access instruction into the third cache; if the first cache does not have a superior third cache, the processor can read data directly from the first cache through the memory access instruction.
[0044] In this step, the hit result of the memory access instruction in the first cache is a miss, indicating that the first cache does not store the data requested to be read by the memory access instruction. At this time, it is necessary to check whether the second cache under the first cache has the data. If the data is stored in the second cache, let the second cache refill the data into the first cache. Therefore, when the hit result is a miss, the embodiment of the present application can suspend the memory access instruction and send a fetch request to the second cache through the first cache to request the second cache to find the refill data required by the memory access instruction and send it to the first cache. In addition, when the hit result is a miss, the embodiment of the present application does not need to immediately find the target data block in the first cache for release, so that during the period before the refill data arrives, the target data block storing the old data can operate normally and the old data can also be accessed normally. The second cache is a lower-level cache of the first cache. For example, for the three-level cache structure: first-level cache L1, second-level cache L2 and third-level cache L3, assuming that the first cache is first-level cache L1, then the second-level cache can be second-level cache L2; assuming that the first cache is second-level cache L2, then the second-level cache can be third-level cache L3.
[0045] It should be noted that, refer to Figure 3 When the hit result of the memory access instruction in the first cache is a miss, the memory access instruction is suspended, which means that the memory access instruction is separated from the pipeline queue of the first cache and enters an allocated miss status register (MSHR, Miss-status Handling Registers) for waiting. The miss status register is a register used to record each unfinished transaction. The recorded information includes the invalid address, keyword information, and unfinished instructions. Once the second cache refills the first cache, the memory access instruction in the miss status register can be re-executed. The re-executed memory access instruction can re-enter the pipeline queue of the first cache.
[0046] Step 103: When the first cache receives the refill data sent by the second cache in response to the acquisition request, determine the target data block from the first cache, release the old data stored in the target data block, and write the refill data into the target data block.
[0047] In an embodiment of the present application, the process in which the second cache responds to the acquisition request to search and obtain the refill data and send it to the first cache usually takes a long time (it takes dozens to hundreds of data bits in the pipeline of the first cache). However, during the time when the first cache waits for the refill data to be sent, the embodiment of the present application does not release or occupy the data block containing the old data, thereby improving the utilization rate of the cache resources while ensuring that the old data can be accessed normally.
[0048] Furthermore, in the embodiment of the present application, the target data block is selected only when the refill data sent by the second cache is received through the first cache. If the target data block stores old data, the old data is released and the refill data is written into the target data block. In this way, during the period before the refill data arrives, the data block storing the old data in the first cache can operate normally and is not vacant or occupied, and the old data can also be accessed normally. After the first cache receives the refill data, the old data stored in the selected target data block is released, and the refill data is written into the target data block, which also ensures the normal implementation of the data reading process of the memory access instruction.
[0049] In summary, in the embodiments of the present application, when a memory access instruction does not hit in the first cache, the data block is not selected for release first, but the subordinate second cache is notified to obtain the refill data required for the memory access request, and waits for the second cache to obtain the refill data and send the refill data to the first cache, and then the target data block is determined from the first cache, and the old data stored in the target data block is released, and the refill data is written into the target data block. In this way, during the period before the arrival of the refill data, the data block storing the old data operates normally and is not vacant or occupied, and the old data can also be accessed normally. In addition, after the first cache receives the refill data, the present application releases the old data stored in the selected target data block, which also ensures the normal implementation of the old data reading process of the memory access instruction during this period.
[0050] Figure 4 is a flowchart of the specific steps of a method for processing refill data provided by an embodiment of the present application, such as Figure 4 As shown, the method may include:
[0051] Step 201: When a memory access instruction of a processor is obtained through a first cache, a hit result of the memory access instruction in the first cache is obtained.
[0052] This step may specifically refer to the above step 101, which will not be described in detail here.
[0053] Step 202: If the hit result is a miss, the memory access instruction is controlled to leave the pipeline queue and enter the missing state register for suspended waiting, and at the same time, a fetch request is sent to a second cache through the first cache; the second cache is a lower-level cache of the first cache.
[0054] In the embodiments of this application, refer to Figure 3 , the hit result of the memory access instruction in the first cache is a miss, indicating that the data requested to be read by the memory access instruction is not stored in the first cache. At this time, it is necessary to send a get request to the lower-level second cache through the first cache to check whether the lower-level second cache has the data. If the data is stored in the second cache, the second cache responds to the get request and refills the data into the first cache.
[0055] Specifically, when the hit result is a miss, the memory access instruction can be removed from the pipeline queue of the first cache and enter an allocated miss status register (MSHR) for waiting. The miss status register is a register used to record each unfinished transaction. Once the second cache completes the refill of the first cache, the memory access instruction in the miss status register can be re-executed, and the re-executed memory access instruction can re-enter the pipeline queue of the first cache.
[0056] Among them, the memory access instruction is separated from the pipeline queue of the first cache because the data requested by the memory access instruction is not stored in the first cache, which causes the memory access instruction to currently fail to realize data reading. Therefore, the memory access instruction is first separated from the pipeline queue of the first cache and enters the missing status register to wait, so as to avoid interfering with the execution of other requests of the first cache. After waiting for the lower-level second cache to send the data requested by the memory access instruction to the first cache, the data requested by the memory access instruction has been obtained by the first cache. Then, the memory access instruction in the missing status register can enter the pipeline queue of the first cache again, so as to correctly read the data in the first cache.
[0057] Step 203: When the refill data sent by the second cache in response to the acquisition request is received through the first cache, the first cache directory is read starting from the starting data bit of the pipeline queue of the first cache, and after an interval of a first number of data bits, the target data block is determined from the first cache according to the first cache directory.
[0058] In the embodiments of this application, refer to Figure 5 , which shows another schematic diagram of the architecture of the first cache, Figure 5 It is a connection Figure 3In the first cache processing process, when the refill data sent by the second cache in response to the acquisition request is received through the first cache, the data requested by the memory access instruction has been obtained by the first cache, and the memory access instruction in the missing status register can enter the pipeline queue of the first cache again. Specifically, the memory access instruction can enter the pipeline from the starting data bit (S1 data bit) of the pipeline queue of the first cache, and read the first cache directory from the starting data bit (S1 data bit). The first cache directory is a data that represents the directory of data stored in the first cache. By reading the first cache directory, a target data block can be determined from the first cache to release and store the refill data.
[0059] Optionally, step 203 may specifically include sub-steps 2031-2032:
[0060] Sub-step 2031: According to the first cache directory, obtain the last access time of each data block in the first cache.
[0061] Sub-step 2032: taking the data block with the earliest last access time as the target data block.
[0062] In one implementation of an embodiment of the present application, for sub-steps 2031-2032, the first cache directory records the last access time of each data block in the first cache. The embodiment of the present application can obtain the last access time of each data block in the first cache based on the first cache directory, and use the data block with the earliest last access time as the target data block. The data block with the earliest last access time indicates that the data stored in the data block is the least active. Therefore, by using the data block with the earliest last access time as the target data block, the impact on the more active data in other data blocks can be minimized.
[0063] In another implementation of the embodiment of the present application, a data block may be randomly selected from the first cache as the target data block, and the embodiment of the present application does not specifically limit the selection strategy of the target data block.
[0064] Optionally, step 203 may further include sub-steps 2033-2034:
[0065] Sub-step 2033: When receiving, through the first cache, the refill data sent by the second cache in response to the acquisition request, detecting the storage status of the first cache.
[0066] Sub-step 2034: when it is determined that the storage status is: there is no free data block in the first cache that can store the refill data, determine a target data block from the first cache.
[0067] In an embodiment of the present application, with respect to sub-steps 2033-2034, specifically before determining the target data block in the first cache, the storage status of the first cache can be first detected. If the storage status is that there are free data blocks in the first cache that can store the refill data, the free data blocks are directly used as the target data blocks. However, when a capacity conflict occurs in the first cache (there are no free data blocks in the first cache that can store the refill data), it is necessary to determine the target data block from the first cache through the method of the above embodiment, release the old data in the target data block to make it a free data block, and write the refill data into the free target data block.
[0068] Step 204: Write the refill data into the refill buffer area of the first cache.
[0069] In the embodiments of this application, refer to Figure 5 When the first cache just receives the refill data sent by the second cache of the lower level (the refill data has not been written to the target data block at this time), it is necessary to temporarily store the refill data before writing the refill data to the target data block. Therefore, an independent refill buffer area can be set up in the first cache, and the first cache can write the refill data into the refill buffer area for temporary storage.
[0070] Step 205, read the refill buffer area at the data bit after the starting data bit, and read the refill data after an interval of a second number of data bits, write the read refill data into the write buffer area of the first cache, and read the old data in the target data block.
[0071] In the embodiments of this application, refer to Figure 5 , the operation of reading the refill buffer area is started at the data bit (S2 data bit) after the starting data bit (S1 data bit) of the pipeline queue of the first cache. Since it takes a fixed time for the first cache to read the refill buffer area from the beginning to read the refill buffer area to read the refill data (corresponding to the pipeline, it takes a time corresponding to 1 data bit), so after the second number of data bits (1 data bit interval), the refill data can be read at the S3 data bit.
[0072] In the S3 data bit of the pipeline queue of the first cache, while the first cache reads the refill data from the refill buffer area, the first cache can also write the refill data to the write buffer area of the first cache (not shown in the figure). The write buffer area is an independent storage area established in the first cache. Its function is to determine whether to write the refill data to the target data block based on whether a read operation is performed on the target data block, and to write the refill data to the target data block when determining to write.
[0073] Furthermore, in the S3 data bit of the pipeline queue of the first cache, the first cache also synchronously starts an operation of reading old data in the target data block.
[0074] Step 206: After a third number of data bits have been left, the old data obtained by reading is stored in the second cache, thereby completing the release of the target data block.
[0075] In the embodiments of this application, refer to Figure 5 In the S3 data bit of the pipeline queue of the first cache, the first cache also synchronously starts the operation of reading the old data in the target data block. Since it takes a fixed time for the first cache to read the target data block from the beginning to read the old data therein (corresponding to the pipeline, it takes a time corresponding to 2 data bits), after an interval of the third number of data bits (an interval of 2 data bits), the old data in the target data block can be read at the S5 data bit of the pipeline queue of the first cache. At this time, the old data is read out from the target data block.
[0076] Furthermore, the S5 data bit of the pipeline queue of the first cache can also send the read old data to the second cache to complete the release of the target data block.
[0077] It should be noted that after the old data in the target data block is released, if a read instruction for the old data is subsequently received, the first cache still needs to obtain data from the second cache and refill the first cache according to steps 201 to 207 to meet the read instruction's requirement to read the old data.
[0078] Step 207: When it is detected that the operation of reading the target data block is completed, write the refill data in the write buffer area into the target data block.
[0079] In the embodiment of the present application, the function of the write buffer area is to determine whether to write the refill data into the target data block according to the judgment of the read operation performed on the target data block. Specifically, the embodiment of the present application sets a higher priority for the operation of reading the target data block, so the write buffer needs to wait until all the read operations on the target data block are completed before starting the operation of writing the refill data in the write buffer area into the target data block. That is, when the write buffer area determines that all the read operations performed on the target data block are completed, the write buffer area executes the operation of writing the refill data in the write buffer area into the target data block, thereby completing the operation of storing the refill data into the first cache storage unit.
[0080] Optionally, the method may further include:
[0081] Step 208: When the first address carried in the read request received by the first cache matches the second address of the target refill data in the write buffer area, return the target refill data as a response to the read request.
[0082] In an embodiment of the present application, during the period when the target refill data is in the write buffer area and has not yet been written into the target data block, if a read request for the target refill data is received, the target refill data in the write buffer area can be directly returned as a response to the read request. Wherein, when the first address carried by the read request received by the first cache matches the second address of the target refill data in the write buffer area, it is determined that the data requested to be read by the read request is the target refill data in the refill buffer area.
[0083] It should be noted that, in summary, the missing status register can establish two tasks. The first task is used to implement the first cache obtaining refill data from the second cache during the above embodiment; the second task is used to implement the target data block, release the target data block, write the refill data to the target data block, and continue to refill the refill data to the superior cache during the above embodiment.
[0084] Optionally, the method may further include:
[0085] Step 209: After writing the refill data into the target data block, extract the memory access instruction from the missing status register, write the refill data into the third cache, and wake up the operation of reading data from the third cache through the memory access instruction.
[0086] The third cache is an upper-level cache of the first cache; and the memory access instruction misses in the third cache.
[0087] In the embodiment of the present application, when the first cache does not have a third cache of the upper level, the memory access instruction can directly obtain the refill data from the first cache and feed it back to the processor. In the case where the first cache has a third cache of the upper level, after writing the refill data to the target data block, the first cache also needs to extract the memory access instruction from the missing status register, write the refill data to the third cache, and wake up the operation of reading data from the third cache through the memory access instruction, that is, the memory access instruction is to first access the upper cache, if the access to the upper cache does not hit, then access the data of the lower cache for data access, so when the memory access instruction does not hit in the upper third cache, after the lower second cache writes the refill data into the first cache of the current level, the first cache also needs to refill the refill data into the upper third cache, and when the third cache has no upper cache, the operation of reading data from the third cache through the memory access instruction can be awakened, and the awakened memory access instruction can directly obtain the refill data from the third cache and feed it back to the processor. Similarly, when the third cache also has a higher cache, the third cache still needs to continue to refill the refill data into the higher cache.
[0088] Optionally, step 209 may specifically include sub-steps 2091-2092:
[0089] Sub-step 2091: Control the memory access instruction to enter the pipeline queue of the first cache from the starting data bit, and at the same time generate a wake-up instruction through the first cache and send it to the third cache through the wake-up queue.
[0090] Sub-step 2092: after spacing out the second number of data bits in the pipeline queue, obtain refill data through the first cache, and issue the memory access instruction as a refill instruction from the refill queue to the third cache.
[0091] The wake-up instruction is used to wake up the operation of reading data from the third cache through the memory access instruction; and the refill instruction is used to write the refill data into the third cache for reading by the memory access instruction.
[0092] In an embodiment of the present application, the hit result is a miss, indicating that the data requested to be read by the memory access instruction is not stored in the first cache. At this time, it is necessary to check whether the data is stored in the lower-level second cache. If the data is stored in the second cache, the second cache is allowed to refill the data into the first cache for reading by the memory access instruction.
[0093] Specifically, refer to Figure 3, after waiting for the second cache to refill the first cache, control the memory access instruction to re-enter the pipeline queue from the starting data bit, and at the same time generate a wake-up instruction through the first cache and send it from the wake-up queue to the upper third cache (the moment of entering the wake-up queue and sending the wake-up instruction is the moment corresponding to the data bit S1); and after an interval of the second number of data bits (an interval of 2 data bits), obtain the refill data through the first cache, and send the memory access instruction as a refill instruction from the refill queue to the third cache.
[0094] For example, refer to Figure 3 In the case where the hit result is a miss, the actual sending time of the wake-up request is the moment corresponding to data bit S1. Since the refill request has to wait in the refill queue for the length of time represented by a data bit (ensuring that the refill request at the exit of the refill queue is issued in time to reduce the probability of congestion in the refill queue), the actual sending time of the refill request is the moment corresponding to data bit S4. It can be seen that the embodiment of the present application can ensure that for each refill request, a wake-up request is issued three data bits in advance.
[0095] The embodiment of the present application realizes the management of memory access instructions through the concise and clear multi-level pipeline queue architecture of the first cache. Based on the pipeline queue, it is designed to obtain the hit result of the memory access instruction and send a wake-up request at a fixed data bit, and to obtain the refill data at another fixed data bit and send the refill request through the refill queue; based on the pipeline queue architecture and the design of each processing time of the instruction in the pipeline, it can achieve accurate and stable control of the fixed advance amount of the wake-up request, ensuring the accuracy and coverage of the memory access instruction reading process. The whole process does not need to read the status of the pipeline requests at each level, and the real-time calculation of the advance issuance time based on the status of the refill queue request, so the complexity is extremely low, reducing the cost and power consumption of the circuit.
[0096] Optionally, the method may further include:
[0097] Step 210: If the hit result is a hit, read the data in the data block hit by the memory access instruction in the first cache and return it.
[0098] In an embodiment of the present application, the hit result of the memory access instruction in the first cache is a hit, indicating that the first cache has the data requested to be read by the memory access instruction. If the first cache also has a third cache of an upper level, the first cache can refill the data requested to be read by the memory access instruction into the third cache; if the first cache does not have a third cache of an upper level, the processor can read data directly from the first cache through the memory access instruction.
[0099] In summary, in the embodiments of the present application, when a memory access instruction misses in the first cache, the data block is not selected for release first, but the subordinate second cache is notified to obtain the refill data required for the memory access request, and when the second cache obtains the refill data and sends the refill data to the first cache, the target data block is determined from the first cache, and the old data stored in the target data block is released, and the refill data is written into the target data block. In this way, during the period before the arrival of the refill data, the data block storing the old data operates normally, is not vacant or occupied, and the old data can also be accessed normally. In addition, after the first cache receives the refill data, the present application releases the old data stored in the selected target data block, which also ensures the normal implementation of the old data reading process of the memory access instruction during this period.
[0100] Figure 6 is a block diagram of a processing device for refilling data provided by an embodiment of the present application, the device comprising:
[0101] The acquisition module 301 is used to acquire a hit result of the memory access instruction in the first cache when the memory access instruction of the processor is acquired through the first cache;
[0102] A miss module 302, configured to suspend the memory access instruction if the hit result is a miss, and send a fetch request to a second cache through the first cache; the second cache is a lower-level cache of the first cache;
[0103] The write module 303 is used to determine the target data block from the first cache, release the old data stored in the target data block, and write the refill data into the target data block when receiving the refill data sent by the second cache in response to the acquisition request through the first cache.
[0104] Optionally, the writing module 303 includes:
[0105] The determination submodule is used to read the first cache directory starting from the start data bit of the pipeline queue of the first cache, and determine the target data block from the first cache according to the first cache directory after an interval of a first number of data bits.
[0106] Optionally, the writing module 303 includes:
[0107] A first writing submodule, used for writing the refill data into a refill buffer area of the first cache;
[0108] a processing submodule, configured to read the refill buffer area at a data bit following the start data bit, and read the refill data after a second number of data bits, write the read refill data into the write buffer area of the first cache, and read old data in the target data block;
[0109] A release submodule, configured to store the read old data into the second cache after a third number of data bits have passed, thereby completing the release of the target data block;
[0110] The second writing submodule is used to write the refill data in the write buffer area into the target data block when it is detected that the operation of reading the target data block is completed.
[0111] Optionally, the device further comprises:
[0112] A return module is used to return the target refill data as a response to the read request when the first address carried by the read request received by the first cache matches the second address of the target refill data in the write buffer area.
[0113] Optionally, the determining submodule includes:
[0114] an acquiring unit, configured to acquire, according to the first cache directory, a last access time of each data block in the first cache;
[0115] The determination unit is used to take the data block with the earliest last access time as the target data block.
[0116] Optionally, the miss module 302 includes:
[0117] The suspend submodule is used to control the memory access instruction to leave the pipeline queue and enter the missing state register to suspend and wait if the hit result is a miss.
[0118] Optionally, the device further comprises:
[0119] a wake-up module, configured to extract the memory access instruction from the missing status register after writing the refill data into the target data block, write the refill data into a third cache, and wake up an operation of reading data from the third cache through the memory access instruction;
[0120] The third cache is an upper-level cache of the first cache; and the memory access instruction misses in the third cache.
[0121] Optionally, the wake-up module includes:
[0122] An entry submodule, used for controlling the memory access instruction to enter the pipeline queue of the first cache from the starting data bit, and generating a wake-up instruction through the first cache and sending it to the third cache through the wake-up queue;
[0123] a sending submodule, configured to obtain refill data through the first cache after the second number of data bits are spaced apart in the pipeline queue, and send the memory access instruction as a refill instruction from the refill queue to the third cache;
[0124] The wake-up instruction is used to wake up the operation of reading data from the third cache through the memory access instruction; and the refill instruction is used to write the refill data into the third cache for reading by the memory access instruction.
[0125] Optionally, the device further comprises:
[0126] A hit module is used to read the data in the data block hit by the memory access instruction in the first cache and return it if the hit result is a hit.
[0127] Optionally, the writing module 303 includes:
[0128] a detection submodule, configured to detect a storage status of the first cache when receiving, through the first cache, refill data sent by the second cache in response to the acquisition request;
[0129] The full-load submodule is used to determine a target data block from the first cache when it is determined that the storage status is: there is no free data block in the first cache that can store the refill data.
[0130] In summary, in the embodiments of the present application, when a memory access instruction misses in the first cache, the data block is not selected for release first, but the subordinate second cache is notified to obtain the refill data required for the memory access request, and when the second cache obtains the refill data and sends the refill data to the first cache, the target data block is determined from the first cache, and the old data stored in the target data block is released, and the refill data is written into the target data block. In this way, during the period before the arrival of the refill data, the data block storing the old data operates normally, is not vacant or occupied, and the old data can also be accessed normally. In addition, after the first cache receives the refill data, the present application releases the old data stored in the selected target data block, which also ensures the normal implementation of the old data reading process of the memory access instruction during this period.
[0131] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0132] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0133] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0134] An embodiment of the present application provides a processing device for refilling data, including a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to include methods for performing one or more of the above embodiments.
[0135] Figure 7 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0136] Reference Figure 7 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0137] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0138] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0139] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0140] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0141] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0142] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0143] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0144] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0145] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement the methods provided in the embodiments of the present application.
[0146] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0147] Figure 8is a block diagram of an electronic device 700 according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Figure 8 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions that can be executed by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform the method provided in the embodiment of the present application.
[0148] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0149] An embodiment of the present application further provides a computer program product, including a computer program, which implements the method described in the above embodiment when executed by a processor.
[0150] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0151] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for processing refill data, characterized in that: The method comprises: In the case where a memory access instruction of the processor is obtained through the first cache, obtaining a hit result of the memory access instruction in the first cache; If the hit result is a miss, the memory access instruction is suspended, and a fetch request is sent to a second cache through the first cache; the second cache is a lower-level cache of the first cache; When receiving the refill data sent by the second cache in response to the acquisition request through the first cache, determining a target data block from the first cache, releasing old data stored in the target data block, and writing the refill data into the target data block; If the hit result is a miss, suspending the memory access instruction comprises: If the hit result is a miss, the memory access instruction is controlled to leave the pipeline queue and enter the missing state register to suspend and wait; The determining the target data block from the first cache includes: Reading a first cache directory from a start data bit of a pipeline queue of the first cache, and determining the target data block from the first cache according to the first cache directory after a first number of data bits have been separated; The obtaining a hit result of the memory access instruction in the first cache includes: After the memory access instruction enters the pipeline from the starting data bit of the pipeline queue, a hit result of the memory access instruction in the first cache is obtained after a fixed number of data bits have passed; The method further comprises: After writing the refill data into the target data block, extracting the memory access instruction from the missing status register, and executing an operation of writing the refill data into the third cache at a preset data bit, and executing an operation of waking up and reading data from the third cache through the memory access instruction at another preset data bit; The third cache is an upper-level cache of the first cache; and the memory access instruction misses in the third cache.
2. The method for processing refill data according to claim 1, characterized in that: The releasing the old data stored in the target data block and writing the refill data into the target data block comprises: Writing the refill data into a refill buffer area of the first cache; At a data bit following the start data bit, the refill buffer area is read, and after a second number of data bits have passed, the refill data is read and obtained, the refill data obtained by reading is written into the write buffer area of the first cache, and old data in the target data block is read; After a third number of data bits have been left, storing the read old data into the second cache, and completing the release of the target data block; When it is detected that the operation of reading the target data block is finished, the refill data in the write buffer area is written into the target data block.
3. The method for processing refill data according to claim 2, characterized in that: The method further comprises: When a first address carried in the read request received by the first cache matches a second address of target refill data in the write buffer area, the target refill data is returned as a response to the read request.
4. The method for processing refill data according to claim 1, characterized in that: The determining the target data block from the first cache according to the first cache directory includes: According to the first cache directory, obtaining the last access time of each data block in the first cache; The data block with the earliest last access time is used as the target data block.
5. The method for processing refill data according to claim 1, characterized in that: The method further comprises: After the refill data is written into the target data block, the memory access instruction is extracted from the missing status register, the refill data is written into the third cache, and the operation of reading data from the third cache through the memory access instruction is awakened.
6. The method for processing refill data according to claim 5, characterized in that: The operation of writing the refill data into the third cache and awakening the operation of reading data from the third cache through the memory access instruction includes: Control the memory access instruction to enter the pipeline queue of the first cache from the starting data bit, and at the same time generate a wake-up instruction through the first cache and send it to the third cache through the wake-up queue; After a second number of data bits are spaced apart in the pipeline queue, refill data is obtained through the first cache, and the memory access instruction is issued from the refill queue to the third cache as a refill instruction; The wake-up instruction is used to wake up the operation of reading data from the third cache through the memory access instruction; and the refill instruction is used to write the refill data into the third cache for reading by the memory access instruction.
7. The method for processing refill data according to claim 1, characterized in that: The method further comprises: If the hit result is a hit, the data in the data block hit by the memory access instruction in the first cache is read and returned.
8. The method for processing refill data according to claim 1, characterized in that: When receiving, through the first cache, the refill data sent by the second cache in response to the acquisition request, determining the target data block from the first cache comprises: When receiving, through the first cache, the refill data sent by the second cache in response to the acquisition request, detecting a storage status of the first cache; When it is determined that the storage status is that there is no free data block in the first cache that can store the refill data, a target data block is determined from the first cache.
9. A processing device for refilling data, characterized in that: The device comprises: an acquisition module, configured to acquire, when a memory access instruction of a processor is acquired through a first cache, a hit result of the memory access instruction in the first cache; a miss module, configured to suspend the memory access instruction if the hit result is a miss, and send a fetch request to a second cache through the first cache; the second cache is a lower-level cache of the first cache; a writing module, configured to, upon receiving, through the first cache, the refill data sent by the second cache in response to the acquisition request, determine a target data block from the first cache, release old data stored in the target data block, and write the refill data into the target data block; The miss module comprises: A suspension submodule, used for controlling the memory access instruction to leave the pipeline queue and enter the missing state register to suspend and wait if the hit result is a miss; The writing module comprises: a determination submodule, configured to read a first cache directory starting from a start data bit of a pipeline queue of the first cache, and determine the target data block from the first cache according to the first cache directory after an interval of a first number of data bits; The acquisition module is used to: after the memory access instruction enters the pipeline from the starting data bit of the pipeline queue, after a fixed number of data bits have passed, acquire the hit result of the memory access instruction in the first cache; The device is also used for: After writing the refill data into the target data block, extracting the memory access instruction from the missing status register, and executing an operation of writing the refill data into the third cache at a preset data bit, and executing an operation of waking up and reading data from the third cache through the memory access instruction at another preset data bit; The third cache is an upper-level cache of the first cache; and the memory access instruction misses in the third cache.
10. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 8.
