CN114610656A - Data replacement method and device, electronic equipment and storage medium - Google Patents

Data replacement method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114610656A
CN114610656A CN202210181764.XA CN202210181764A CN114610656A CN 114610656 A CN114610656 A CN 114610656A CN 202210181764 A CN202210181764 A CN 202210181764A CN 114610656 A CN114610656 A CN 114610656A
Authority
CN
China
Prior art keywords
replacement
priority
cache line
access request
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210181764.XA
Other languages
Chinese (zh)
Inventor
刘苏
苏孟豪
黄帅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN202210181764.XA priority Critical patent/CN114610656A/en
Publication of CN114610656A publication Critical patent/CN114610656A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0877Cache access modes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0893Caches characterised by their organisation or structure
    • G06F12/0895Caches characterised by their organisation or structure of parts of caches, e.g. directory or tag array

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention provides a data replacement method and device. The method comprises the following steps: according to a first block streaming data identifier carried in a first access request, changing the replacement priority of a target cache line corresponding to the first access request into priority not to be replaced, and when the cache line needs to be subjected to data replacement, preferentially replacing the cache lines except the target cache line which is not replaced preferentially according to the replacement priority of the cache line, so that when streaming data just starts to be used, the target cache line for storing the streaming data is changed into priority not to be replaced, the subsequent streaming data is prevented from being replaced without being used, the data replacement of an improper cache line is avoided, and the performance loss is reduced.

Description

Data replacement method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data replacement method, a data replacement apparatus, an electronic device, and a readable storage medium.
Background
A cache (cache) is a memory with a relatively fast speed between a Central Processing Unit (CPU) and a main memory (memory) for caching a part of the contents of the main memory. Caches may provide faster access to the processor core relative to direct access to main memory. In modern computer systems, not limited to central processor cores, Graphics Processing Units (GPUs) and other IO (Input and Output) devices may also use caches to improve performance in accessing memory. For example, the GPU may have a cache itself or share the cache with the CPU, and the IO device controller may access the cache by Direct Cache Access (DCA) or the like.
The content stored in the cache is a part of the memory, so when the data stored in the memory is called into the cache, a certain rule is needed to specify the position of the data with a specific address in the cache, which is called as a mapping mode. Common mapping modes include full association, direct association and group association, wherein the full association indicates that a data block in a memory can be placed at any position in the cache, the direct association indicates that the data block in the memory has a unique position in the cache, the group association is between the full association and the direct association, and the data block in the memory has an available position in each group in the cache. Cache in today's computer systems often uses set associative, where each "set" may also be referred to as a "way". For example, if the cache contains 4 sets, it is referred to as a four-way set associative.
When new data is called into the cache, an original block of data (namely cache line) in the cache needs to be replaced, and in the four-way set associative cache, one way needs to be selected from 4 ways for replacement. Common replacement strategies include random replacement, Least Recently Used (LRU) replacement, First In First Out (FIFO) replacement, and the like.
Different replacement strategies can significantly affect the performance of the cache, and poor replacement selection can result in reduced overall system performance. For example, if a cache line needs to be used again after being replaced, the cache line needs to be called from the memory again, which brings considerable performance loss; if a cache line is retained in the cache but cannot be reused, the cache capacity is reduced, and performance loss is also brought.
In a computer system, there are many streaming data to be used, such as memory copy of CPU, data transfer of IO controller, etc. These streaming data have distinct characteristics: its producer and consumer often use the data only once each, i.e. the reuse rate is low; when such data uses cache, the access of the producer and the consumer to the data is often completed in a short time interval, i.e. the reuse time is short; the data volume of the streaming data is large, and the improper cache replacement strategy can cause the performance to be reduced.
The applicant researches and shows that the problems of the prior art that the unused streaming data is replaced exist.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present invention is to provide a data replacement method, apparatus, electronic device and readable storage medium, so as to solve the problem that streaming data that is not used is replaced.
In order to solve the above problem, the present invention provides a data replacement method, including:
changing the replacement priority of a target cache line corresponding to a first access request into priority without replacement according to a first block streaming data identifier carried in the first access request; a target cache line corresponding to the first access request is a cache line where streaming data requested by the first access request is located;
and when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the cache lines except the target cache line which is preferentially not replaced according to the replacement priority of the cache line.
Optionally, the changing, according to the first block streaming data identifier carried in the first access request, the replacement priority of the target cache line corresponding to the first access request to a priority not to be replaced includes:
determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority level without replacement; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
Optionally, the method further comprises:
changing the replacement priority of a target cache line corresponding to a second access request into priority replacement according to the last block of streaming data identification carried in the second access request; a target cache line corresponding to the second access request is a cache line where streaming data requested by the second access request is located;
and when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the target cache line corresponding to the second access request which is preferentially replaced according to the replacement priority of the cache line.
Optionally, before changing the replacement priority of the target cache line corresponding to the first access request to be priority for non-replacement according to the first block streaming data identifier carried in the first access request, the method further includes:
adding the first block streaming data identifier to a first access request in a plurality of access requests aiming at streaming data to obtain the first access request;
or, in a plurality of access requests for streaming data, adding the first block streaming data identifier to an access request every other streaming data corresponding to the cache line size to obtain the first access request.
Optionally, before changing the replacement priority of the target cache line corresponding to the second access request to the priority replacement according to the last block of streaming data identifier carried in the second access request, the method further includes:
adding the last block of streaming data identification to the last access request in a plurality of access requests aiming at streaming data to obtain a second access request;
or, in a plurality of access requests for the streaming data, adding the last block of streaming data identifier to the access request every other streaming data corresponding to the cache line size to obtain the second access request.
Optionally, the replacing priority includes priority replacement, normal replacement, and priority non-replacement, and when the cache line needs to be replaced with data, preferentially replacing the cache line other than the target cache line that is not replaced with priority according to the replacing priority of the cache line includes:
receiving a data replacement request;
if the cache line with the replacement priority as the priority for replacement exists, randomly selecting one cache line with the priority for replacement to perform data replacement;
if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement exists, selecting one cache line with the normal replacement for data replacement;
and if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement does not exist, selecting one cache line from the cache lines except the cache line with the priority replacement and the cache line with the normal replacement for performing data replacement.
Optionally, the replacement priority includes a priority replacement, a normal replacement, and a priority non-replacement, and the method further includes:
when the cache is reset or the target cache line is subjected to data replacement, the replacement priority of the target cache line is changed into normal replacement.
The invention also provides a data replacement device, comprising:
the first priority changing module is used for changing the replacement priority of a target cache line corresponding to a first access request into priority without replacement according to a first block streaming data identifier carried in the first access request; wherein the target cache line is a cache line in which streaming data requested by the first access request is located;
and the first data replacement module is used for preferentially performing data replacement on the cache lines except the target cache line which is not replaced preferentially according to the replacement priority of the cache line when the cache line needs to perform data replacement.
Optionally, the first priority changing module includes:
the target determining submodule is used for determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
the state modification submodule is used for modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority not to be replaced; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
Optionally, the apparatus further comprises:
the second priority changing module is used for changing the replacement priority of the target cache line corresponding to the second access request into priority replacement according to the last block of streaming data identifier carried in the second access request;
and the second data replacement module is used for preferentially performing data replacement on the target cache line which is preferentially replaced according to the replacement priority of the cache line when the cache line needs to perform data replacement.
Optionally, the apparatus further comprises:
a first identifier adding module, configured to add, in multiple access requests for streaming data, a first block streaming data identifier to a first access request to obtain a first access request before changing, according to the first block streaming data identifier carried in the first access request, a replacement priority of a target cache line corresponding to the first access request to priority without replacement;
or, the second identifier adding module is configured to add, to the access request, the first block streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the first access request.
Optionally, the apparatus further comprises:
a third identifier adding module, configured to add, in multiple access requests for streaming data, a last block of streaming data identifier to a last access request before changing, according to a last block of streaming data identifier carried in a second access request, a replacement priority of a target cache line corresponding to the second access request to a priority replacement, so as to obtain the second access request;
or, the fourth identifier adding module is configured to add, to the access request, the last block of streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the second access request.
Optionally, the replacement priority includes priority replacement, normal replacement, and priority non-replacement, and the first data replacement module includes:
the request receiving submodule is used for receiving a data replacement request;
the first data replacement submodule is used for randomly selecting a cache line with priority replacement for data replacement if the cache line with priority replacement exists;
the second data replacement submodule is used for selecting a normally replaced cache line for data replacement if the cache line with the replacement priority as the priority for replacement does not exist and the cache line with the replacement priority as the normal replacement exists;
and the third data replacement submodule is used for selecting one cache line from the cache lines except the cache lines with the priority replacement and the normal replacement for performing data replacement if the cache line with the priority replacement is absent and the cache line with the normal replacement priority is absent.
Optionally, the replacement priority includes priority replacement, normal replacement, priority not replacement, and the apparatus further includes:
and the third priority changing module is used for changing the replacement priority of the target cache line into normal replacement when the cache is reset or after the target cache line is subjected to data replacement.
The embodiment of the invention also discloses electronic equipment which is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory finish mutual communication through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps as described above when executing the program stored in the memory.
The embodiment of the invention also discloses a readable storage medium, and when the instructions in the storage medium are executed by a processor of the electronic equipment, the electronic equipment can execute one or more methods in the embodiment of the invention.
According to the embodiment of the invention, the replacement priority of the target cache line corresponding to the first access request is changed into priority not to be replaced according to the first block streaming data identifier carried in the first access request, and when the cache line needs to be replaced with data, the cache line except the target cache line which is not replaced with priority is replaced with priority according to the replacement priority of the cache line, so that the target cache line storing the streaming data is changed into priority not to be replaced when the streaming data is just used, the subsequent streaming data is prevented from being replaced without being used, the data replacement of an improper cache line is avoided, and the performance loss is reduced.
Drawings
FIG. 1 is a flow chart illustrating the steps of a data replacement method provided by an embodiment of the present invention;
FIG. 2 shows a schematic diagram of a cache and its connected devices;
FIG. 3 shows a schematic of the inside of a cache;
FIG. 4 is a schematic diagram showing the structure of a data replacement apparatus;
FIG. 5 is a schematic diagram illustrating a data replacement flow;
FIG. 6 is a flow chart illustrating steps of a data replacement method provided by another embodiment of the present invention;
FIG. 7 is a diagram illustrating an alternative priority translation relationship;
fig. 8 is a block diagram illustrating an embodiment of a data replacement device according to another embodiment of the present invention;
FIG. 9 illustrates a block diagram of an electronic device for data replacement, according to an example embodiment.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, a flowchart illustrating steps of a data replacement method provided in an embodiment of the present invention is shown, which may specifically include the following steps:
step 101, according to a first block streaming data identifier carried in a first access request, changing a replacement priority of a target cache line corresponding to the first access request into priority without replacement.
In this embodiment of the present invention, the first access request includes a request for data in the cache, such as a reading instruction of streaming data, or any other suitable request, and this is not limited in this embodiment of the present invention.
In the embodiment of the present invention, a cache is a group of data blocks of a fixed size called cache line (cache line). A cache line is a memory space that is filled or downloaded during a burst read operation cycle. For example, a schematic diagram of a cache and its connected devices as shown in FIG. 2. The cache is connected with the controller/processor and the memory and is arranged between the controller/processor and the memory. Such as the schematic inside the cache shown in fig. 3. The cache mainly comprises label storage, data storage, control logic, an access request access connected with the controller/processor, and a refill/replacement access connected with the memory. The contents of the tag memory include address high order bits, valid bits and other cache line state information, the contents of the data memory are cache lines, and the control logic includes processing logic for access requests, refill/replace.
In the embodiment of the present invention, when new data is to be loaded into the cache memory, a block of original data in the cache memory, that is, a cache line, needs to be replaced with the new data. Data replacement is an operation that replaces data in a cache line with data in memory.
In the embodiment of the present invention, a replacement priority is set for each cache line to control data replacement of the cache line. Priority not replacement is one of the replacement priorities. The priority non-replacement means that data replacement is performed preferentially on a cache line whose replacement priority is not priority non-replacement at the time of data replacement.
For example, a replacement status bit is set for each cache line to indicate various replacement priorities. The control logic in fig. 3 may use the replacement method of the present invention to perform the data replacement of the cache line according to the replacement status bit, or perform the data replacement of the cache line according to the replacement status bit and other replacement information. The replacement status bit, that is, the implementation manner of the replacement priority may be represented by two data bits, and any applicable implementation manner may be specifically adopted, which is not limited in this embodiment of the present invention. The replacement status bit, i.e. the storage location of the replacement priority bit, may be stored in the tag storage or may be stored in a separate status bit, and different storage locations and manners only affect the design timing and not the essence of the method, which is not limited in the embodiment of the present invention. Other replacement information includes, but is not limited to, the most recent frequency of use of the cache line, the order in which data was stored in the cache line, and the like. According to the replacement state bit and the latest use frequency of the cache line, when the cache line is selected for replacement, other cache lines except for the cache line which is not replaced with priority can be selected preferentially, and in other cache lines, the cache line which is used least recently is selected preferentially for replacement first according to the principle of least recent use. According to the order of the replacement state bits and the data stored in the cache lines, when the cache line is selected for replacement, other cache lines except for the cache line which is not replaced preferentially can be selected preferentially, and in other cache lines, the cache line in which the data is stored first is selected preferentially for replacement according to the first-in first-out principle. Any suitable manner may be adopted, and the embodiment of the present invention is not limited thereto.
In this embodiment of the present invention, the streaming data refers to a group of sequential, large-amount, fast, and continuous data sequences, for example, memory copy of a CPU, data transmission of an IO controller, and the like, or any other suitable streaming data, which is not limited in this embodiment of the present invention.
In the embodiment of the present invention, the identification of the streaming data is implemented by the first block streaming data identifier carried in the first access request. The first block streaming data identification indicates that the streaming data for which the first access request is directed is the first block streaming data. One or more cache lines in which the streaming data requested by the first access request is located are marked as target cache lines. After the first access request is received, when the first access request carries the first block streaming data identifier, the replacement priority of the target cache line corresponding to the first access request is changed into priority without replacement.
In an optional embodiment of the present invention, an implementation manner of changing a replacement priority of a target cache line corresponding to a first access request to a priority not to be replaced according to a first block streaming data identifier carried in the first access request includes: determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request; modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority level without replacement; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
The cache internally comprises tag storage and data storage, wherein the tag storage is divided into tag storage of each cache line. A replacement status bit is added to the tag storage of each cache line to characterize replacement priority. For example, two data bits are used in the tag store of a cache line to represent the replacement status bit. Different replacement priorities are represented by different values, denoted as status values.
After the first access request is received, it is firstly determined that the first access request carries the first block streaming data identifier and a target cache line corresponding to the first access request. And then, the replacement state bit of the target cache line is modified to be a state value corresponding to the priority non-replacement, so that the replacement priority of the target cache line is changed to be the priority non-replacement.
And 102, when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the cache lines except the target cache line which is preferentially not replaced according to the replacement priority of the cache line.
In the embodiment of the invention, the cache line is subjected to data replacement according to the replacement priority of the cache line. When the cache line needs to be replaced with data, the cache line needs to be selected from a plurality of cache lines for data replacement. Since the replacement priority of the target cache line is priority not to be replaced, when a cache line is selected from a plurality of cache lines, a cache line other than the target cache line which is priority not to be replaced is preferentially selected.
It should be understood that when a cache line needs to be replaced, multiple cache lines in the same index in the cache need to be replaced, and the entire cache does not need to be replaced. Therefore, the cache lines except the target cache line which is not replaced preferentially are selected from the cache lines in the part of the cache lines to be replaced first, and the target cache line which is not replaced preferentially is subjected to data replacement only when the cache lines except the target cache line which is not replaced preferentially do not exist.
According to the embodiment of the invention, the replacement priority of the target cache line corresponding to the first access request is changed into priority not to be replaced according to the first block streaming data identifier carried in the first access request, and when the cache line needs to be subjected to data replacement, the cache line except the target cache line which is not replaced with priority is subjected to data replacement preferentially according to the replacement priority of the cache line, so that when the streaming data is just used, the target cache line for storing the streaming data is changed into priority not to be replaced, the subsequent streaming data is prevented from being replaced when not used, the improper data replacement of the cache line is avoided, and the performance loss is reduced.
In an alternative embodiment of the present invention, the replacement priority comprises priority replacement, normal replacement, priority not replacement, and step 102 comprises: a data replacement request is received. A data replacement request refers to a request to replace data in a cache line. If the cache line with the replacement priority as the priority for replacement exists, randomly selecting one cache line with the priority for replacement to perform data replacement; if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement exists, selecting one cache line with the normal replacement for data replacement; and if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement does not exist, selecting one cache line from the cache lines except the cache line with the priority replacement and the cache line with the normal replacement for data replacement.
For example, when the replacement priorities of all cache lines are only three priorities, i.e., priority replacement, normal replacement, and priority non-replacement, then the cache lines other than the cache lines with priority replacement and normal replacement are referred to as priority non-replacement cache lines. When the replacement priority of all cache lines has other replacement priority between the normal replacement and the priority non-replacement besides the priority replacement, the normal replacement and the priority non-replacement, the cache lines are selected to perform data replacement from the cache lines with other replacement priority.
The priority replacement is one of replacement priorities. The priority replacement means that data replacement is performed preferentially on the cache line whose replacement priority is priority replacement at the time of data replacement. Normal replacement is also one of the replacement priorities. The normal replacement means that, at the time of data replacement, data replacement is performed on the cache line whose replacement priority is the priority replacement, and then data replacement is performed on the cache line whose replacement priority is the normal replacement preferentially.
When the cache line needs to be replaced with data, the cache line needs to be selected from a plurality of cache lines for data replacement. Firstly, whether a cache line with replacement priority as priority replacement exists is inquired, and if the cache line with replacement priority as priority replacement exists, one cache line with replacement priority is randomly selected for data replacement. Secondly, if the cache line with the replacement priority of the replacement priority of the replacement priority of the replacement priority of the replacement priority of the replacement priority of the replacement priority of the replacement of the cache line of the replacement priority of the replacement priority of the replacement priority of the. If there is no cache line with the replacement priority of the priority replacement and no cache line with the replacement priority of the normal replacement, selecting one cache line from the cache lines other than the cache lines with the priority replacement and the normal replacement for data replacement, where the manner of selecting the cache line may include a random manner, a Least Recently Used (LRU) manner, a first-in first-out (FIFO) manner, and the like, which is not limited in this embodiment of the present invention.
For example, the structure of the data replacement device is shown in fig. 4. For example, in the case of data replacement using the LRU scheme, the state bit storage stores therein replacement state bits (i.e., replacement priority) of the cache lines, and the LRU storage stores therein information on the order of the cache lines determined in the LRU scheme. When the requirement of data replacement occurs, the control logic inquires the replacement priority of a plurality of cache lines of the same index according to the replacement priority in the index inquiry state bit storage. It is then determined whether there is a cache line that is preferentially replaced based on the replacement priority. When the cache line with priority replacement does not exist, selecting a normally replaced cache line for replacement according to the information stored by the LRU. A schematic diagram of the data replacement flow shown in fig. 5. A refilled cache line is received. The replacement priority of the cache line is derived from reading the status bit storage and/or the storage required by the general replacement algorithm (e.g., LRU storage). And determining whether the cache line which is replaced preferentially exists, and if the cache line which is replaced preferentially exists, randomly selecting one cache line which is replaced preferentially to perform data replacement. And if the cache lines which are replaced preferentially do not exist, determining whether the cache lines which are replaced normally exist, and if the cache lines which are replaced normally exist, selecting one cache line from the cache lines which are replaced normally according to a general replacement algorithm to replace the data. And if the normally replaced cache line does not exist, selecting one cache line for data replacement according to a common replacement algorithm.
Referring to fig. 6, a flowchart illustrating steps of a data replacement method according to an embodiment of the present invention is shown, which may specifically include the following steps:
step 201, according to a first block streaming data identifier carried in a first access request, changing a replacement priority of a target cache line corresponding to the first access request to a priority not to be replaced.
In the embodiment of the present invention, reference may be made to the description in the foregoing embodiment for specific implementation of this step, and details are not described herein.
Step 202, when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the cache lines except the target cache line which is preferentially not replaced according to the replacement priority of the cache line.
In the embodiment of the present invention, reference may be made to the description in the foregoing embodiment for specific implementation of this step, and details are not described herein.
Step 203, changing the replacement priority of the target cache line corresponding to the second access request into priority replacement according to the last block of streaming data identifier carried in the second access request.
In this embodiment of the present invention, the second access request includes a request for data in the cache, such as a reading instruction of streaming data, or any other suitable request, and this is not limited in this embodiment of the present invention. The streaming data requested by the second access request and the streaming data requested by the first access request are the same streaming data, that is, the target cache line corresponding to the second access request is the same as the target cache line corresponding to the first access request.
In the embodiment of the invention, the identification of the streaming data is realized by the streaming data identification carried in the access request. The streaming data identification comprises a first block of streaming data identification and a last block of streaming data identification. The last block of streaming data identification indicates that the streaming data for which the second access request is directed is the last block of streaming data. In one implementation, the first block of streaming data identification and the last block of streaming data identification may be added in the access request by a program using the streaming data. The one or more cache lines in which the streaming data requested by the second access request is located are also target cache lines. And after the second access request is received, when the last block of streaming data identifier is carried in the second access request, changing the replacement priority of the target cache line corresponding to the second access request into priority replacement.
And 204, when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the target cache line which is preferentially replaced according to the replacement priority of the cache line.
In the embodiment of the present invention, since the replacement priority of the target cache line is priority replacement, when a cache line is selected from a plurality of cache lines, the target cache line that is preferentially replaced is preferentially selected for data replacement.
According to the embodiment of the invention, the replacement priority of the target cache line corresponding to the first access request is changed into priority not to be replaced according to the first block streaming data identifier carried in the first access request, and when the cache line needs to be replaced with data, the cache line except the target cache line which is not replaced with priority is replaced with priority according to the replacement priority of the cache line, so that the target cache line storing the streaming data is changed into priority not to be replaced when the streaming data is just used, the subsequent streaming data is prevented from being replaced without being used, the data replacement of an improper cache line is avoided, and the performance loss is reduced.
Furthermore, according to the last block of streaming data identifier carried in the second access request, the replacement priority of the target cache line corresponding to the second access request is changed into priority for replacement, and when the cache line needs to be subjected to data replacement, the target cache line which is preferentially replaced according to the replacement priority of the cache line, so that after the streaming data is used up, the target cache line for storing the streaming data is changed into the priority for replacement, the cache line for the streaming data which is not used any more is timely subjected to data replacement, the problem that the streaming data which is not used any more occupies the cache is avoided, and the use performance of the cache is improved.
In an optional embodiment of the present invention, before changing, according to a first block streaming data identifier carried in a first access request, a replacement priority of a target cache line corresponding to the first access request to a priority not to be replaced, the method may further include: adding the first block streaming data identifier to a first access request in a plurality of access requests aiming at streaming data to obtain the first access request; or, in a plurality of access requests for streaming data, adding the first block streaming data identifier to an access request every other streaming data corresponding to the cache line size to obtain the first access request.
The first block streaming data identifier is generated by a processor or a controller that issues the first access request, and a specific generation method should be determined according to actual situations, which is not limited in this embodiment of the present invention.
The cache line size is fixed, e.g., 32 KB. In one implementation, access to streaming data is split into multiple access requests. And adding a first block streaming data identifier to the first access request to obtain the first access request. The size of the streaming data corresponding to at least one access request starting from the first access request approaches or reaches the cache line size.
In another implementation manner, in a plurality of access requests of streaming data, a first access request adds a first block of streaming data identifier, and each time the streaming data reaches the size of a cache line, the first block of streaming data identifier is added to the next access request, so that the first access request can also be obtained. By analogy, a first access request can be obtained every other streaming data corresponding to the cache line size.
In an optional embodiment of the present invention, before changing, according to a last block of streaming data identifier carried in the second access request, a replacement priority of a target cache line corresponding to the second access request to a priority replacement, the method may further include: adding the last block of streaming data identification to the last access request in a plurality of access requests aiming at streaming data to obtain a second access request; or, in a plurality of access requests for the streaming data, adding the last block of streaming data identifier to the access request every other streaming data corresponding to the cache line size to obtain the second access request.
The last block of streaming data identifier is generated by the processor or the controller that issues the second access request, and the specific generation method should be determined according to the actual situation, which is not limited in this embodiment of the present invention.
The cache line size is fixed, e.g., 32 KB. In one implementation, access to streaming data is split into multiple access requests. And adding the last block of streaming data identification to the last access request to obtain a second access request.
In another implementation manner, in a plurality of access requests for streaming data, the first access request adds the last block of streaming data identifier, and when the streaming data reaches the cache line size, the next access request adds the last block of streaming data identifier, so that the second access request can also be obtained. And by analogy, a second access request can be obtained every other streaming data corresponding to the cache line size.
The access request may be a memory access instruction, a reading instruction, or the like of the processor, or may be a memory access request of the controller, or the like.
Taking a processor as an example, the first block of streaming data identifier or the last block of streaming data identifier may be from different memory access instructions, and the instruction encoding includes identification information and is transmitted in a processor pipeline until reaching a corresponding cache. For example, in a series of reading instructions for streaming data, a first reading instruction is set as a reading instruction carrying a first block of streaming data identifier, such as an LDF (load first, first reading instruction), except for a last reading instruction, a middle reading instruction is a general reading instruction, such as an LDS (load stream, stream reading instruction), and for the general reading instruction, the first block of streaming data identifier or the last block of streaming data identifier is added to the reading instruction according to an access address and a cache line size of the general reading instruction in a pipeline; the last reading instruction is set as a reading instruction carrying the identification of the last block of streaming data, such as LDL (load last).
Similarly, a series of write data instructions for streaming data may also be set to a special instruction for the first write data instruction and the last write data instruction to provide the first block of streaming data identification or the last block of streaming data identification. The special instructions may be defined by the programmer or the streaming data may be identified and used by the compiler. Further, if the exact memory access address can be obtained, more special instructions containing the first block of streaming data identifier or the last block of streaming data identifier can be inserted into the streaming data of the cache line size.
Taking the controller as an example, the first block of streaming data identifier or the last block of streaming data identifier may be from different access requests, the controller splits access to large blocks of streaming data in a specific address range into access requests of a certain granularity, and then sends the access requests to the cache, and attaches the access requests to the first block of streaming data identifier or the last block of streaming data identifier according to the line size of the cache.
In an optional embodiment of the present invention, the replacing priority includes priority replacing, normal replacing, priority not replacing, further comprising: when the cache is reset or the target cache line is subjected to data replacement, the replacement priority of the target cache line is changed into normal replacement.
An alternative priority conversion relationship is shown in fig. 7. When a cache line is subjected to data replacement, the replacement priority of the cache line is changed. When the cache is reset, the replacement priority of the cache line is changed into normal replacement. When the access request carries the first block streaming data identifier, the replacement priority of the cache line is changed into priority without replacement; and if the access request carries the last block of streaming data identifier, changing the replacement priority of the cache line into priority replacement. If the cache line has data replacement, the replacement priority of the cache line is changed to normal replacement.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 8, a block diagram of a structure of an embodiment of a data replacement device according to another embodiment of the present invention is shown, which may specifically include the following modules:
a first priority changing module 301, configured to change, according to a first block streaming data identifier carried in a first access request, a replacement priority of a target cache line corresponding to the first access request to be preferentially not replaced; wherein the target cache line is a cache line in which streaming data requested by the first access request is located;
the first data replacement module 302 is configured to preferentially perform data replacement on cache lines other than the target cache line that is preferentially not replaced according to the replacement priority of the cache line when the cache line needs to perform data replacement.
In an optional embodiment of the invention, the first priority changing module comprises:
the target determining submodule is used for determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
the state modification submodule is used for modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority not to be replaced; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
In an optional embodiment of the invention, the apparatus further comprises:
the second priority changing module is used for changing the replacement priority of the target cache line corresponding to the second access request into priority replacement according to the last block of streaming data identifier carried in the second access request;
and the second data replacement module is used for preferentially performing data replacement on the target cache line which is preferentially replaced according to the replacement priority of the cache line when the cache line needs to perform data replacement.
In an optional embodiment of the invention, the apparatus further comprises:
a first identifier adding module, configured to add, in multiple access requests for streaming data, a first block streaming data identifier to a first access request to obtain a first access request before changing, according to the first block streaming data identifier carried in the first access request, a replacement priority of a target cache line corresponding to the first access request to priority without replacement;
or, the second identifier adding module is configured to add, to the access request, the first block streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the first access request.
In an optional embodiment of the invention, the apparatus further comprises:
a third identifier adding module, configured to add, in multiple access requests for streaming data, a last block of streaming data identifier to a last access request before changing, according to a last block of streaming data identifier carried in a second access request, a replacement priority of a target cache line corresponding to the second access request to a priority replacement, so as to obtain the second access request;
or, the fourth identifier adding module is configured to add, to the access request, the last block of streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the second access request.
In an optional embodiment of the present invention, the replacement priority includes priority replacement, normal replacement, and priority non-replacement, and the first data replacement module includes:
the request receiving submodule is used for receiving a data replacement request;
the first data replacement submodule is used for randomly selecting a cache line with priority replacement for data replacement if the cache line with priority replacement exists;
the second data replacement submodule is used for selecting a normally replaced cache line for data replacement if the cache line with the replacement priority as the priority for replacement does not exist and the cache line with the replacement priority as the normal replacement exists;
and the third data replacement submodule is used for selecting one cache line from the cache lines except the cache lines with the priority replacement and the normal replacement for performing data replacement if the cache line with the priority replacement is absent and the cache line with the normal replacement priority is absent.
In an optional embodiment of the present invention, the replacement priority comprises priority replacement, normal replacement, priority not replacement, and the apparatus further comprises:
and the third priority changing module is used for changing the replacement priority of the target cache line into normal replacement when the cache is reset or after the target cache line is subjected to data replacement.
According to the embodiment of the invention, the replacement priority of the target cache line corresponding to the first access request is changed into priority not to be replaced according to the first block streaming data identifier carried in the first access request, and when the cache line needs to be replaced with data, the cache line except the target cache line which is not replaced with priority is replaced with priority according to the replacement priority of the cache line, so that the target cache line storing the streaming data is changed into priority not to be replaced when the streaming data is just used, the subsequent streaming data is prevented from being replaced without being used, the data replacement of an improper cache line is avoided, and the performance loss is reduced.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Fig. 9 is a block diagram illustrating a structure of an electronic device 700 for data replacement according to an example embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 9, electronic device 700 may include one or more of the following components: processing component 702, memory 704, power component 706, multimedia component 708, audio component 710, input/output (I/O) interface 712, sensor component 714, and communications component 716.
The processing component 702 generally controls overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 702 may include one or more processors 720 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 702 may include one or more modules that facilitate interaction between the processing component 702 and other components. For example, the processing component 702 can include a multimedia module to facilitate interaction between the multimedia component 708 and the processing component 702.
The memory 704 is configured to store various types of data to support operation at the device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 704 may be implemented by any type or combination of volatile or non-volatile memory devices 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 or optical disks.
The power component 704 provides power to the various components of the electronic device 700. Power components 704 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for electronic device 700.
The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and a 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 an input signal from a 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 boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 700 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 710 is configured to output and/or input audio signals. For example, the audio component 710 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 700 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 704 or transmitted via the communication component 716. In some embodiments, audio component 710 further includes a speaker for outputting audio signals.
The I/O interface 712 provides an interface between the processing component 702 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 may detect an open/closed state of the device 700, the relative positioning of components, such as a display and keypad of the electronic device 700, the sensor assembly 714 may also detect a change in the position of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, orientation or acceleration/deceleration of the electronic device 700, and a change in the temperature of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 714 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 714 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 700 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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 704 comprising instructions, executable by the processor 720 of the electronic device 700 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of a terminal, enable the terminal to perform a data replacement method, the method comprising:
changing the replacement priority of a target cache line corresponding to a first access request into priority without replacement according to a first block streaming data identifier carried in the first access request; wherein the target cache line is a cache line in which streaming data requested by the first access request is located;
and when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the cache lines except the target cache line which is preferentially not replaced according to the replacement priority of the cache line.
Optionally, the changing, according to the first block streaming data identifier carried in the first access request, the replacement priority of the target cache line corresponding to the first access request to a priority not to be replaced includes:
determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority level without replacement; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
Optionally, the method further comprises:
changing the replacement priority of a target cache line corresponding to a second access request into priority replacement according to the last block of streaming data identification carried in the second access request;
and when the cache line needs to be subjected to data replacement, preferentially performing the data replacement on the target cache line which is preferentially replaced according to the replacement priority of the cache line.
Optionally, before changing the replacement priority of the target cache line corresponding to the first access request to be priority for non-replacement according to the first block streaming data identifier carried in the first access request, the method further includes:
adding the first block streaming data identifier to a first access request in a plurality of access requests aiming at streaming data to obtain the first access request;
or, in a plurality of access requests for streaming data, adding the first block streaming data identifier to an access request every other streaming data corresponding to the cache line size to obtain the first access request.
Optionally, before changing the replacement priority of the target cache line corresponding to the second access request to the priority replacement according to the last block of streaming data identifier carried in the second access request, the method further includes:
adding the last block of streaming data identification to the last access request in a plurality of access requests aiming at streaming data to obtain a second access request;
or, in a plurality of access requests for the streaming data, adding the last block of streaming data identifier to the access request every other streaming data corresponding to the cache line size to obtain the second access request.
Optionally, the replacing priority includes priority replacement, normal replacement, and priority non-replacement, and when the cache line needs to be replaced with data, preferentially replacing the cache line other than the target cache line that is not replaced with priority according to the replacing priority of the cache line includes:
receiving a data replacement request;
if the cache line with the replacement priority as the priority for replacement exists, randomly selecting one cache line with the priority for replacement to perform data replacement;
if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement exists, selecting one cache line with the normal replacement for data replacement;
and if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement does not exist, selecting one cache line from the cache lines except the cache line with the priority replacement and the cache line with the normal replacement for data replacement.
Optionally, the replacement priority includes a priority replacement, a normal replacement, and a priority non-replacement, and the method further includes:
when the cache is reset or the target cache line is subjected to data replacement, the replacement priority of the target cache line is changed into normal replacement.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The data replacement method, the data replacement apparatus, the electronic device, and the readable storage medium provided by the present invention are described in detail above, and specific examples are applied herein to illustrate the principles and embodiments of the present invention, and the descriptions of the above embodiments are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (16)

1. A method of data replacement, comprising:
changing the replacement priority of a target cache line corresponding to a first access request into priority without replacement according to a first block streaming data identifier carried in the first access request; a target cache line corresponding to the first access request is a cache line where streaming data requested by the first access request is located;
and when the cache line needs to be subjected to data replacement, preferentially performing data replacement on the cache lines except the target cache line which is preferentially not replaced according to the replacement priority of the cache line.
2. The method according to claim 1, wherein changing the replacement priority of the target cache line corresponding to the first access request to a priority not to be replaced according to the first block streaming data identifier carried in the first access request comprises:
determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority level without replacement; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
3. The method of claim 1, further comprising:
changing the replacement priority of a target cache line corresponding to a second access request into priority replacement according to the last block of streaming data identification carried in the second access request; a target cache line corresponding to the second access request is a cache line where streaming data requested by the second access request is located;
and when the cache line needs to perform data replacement, preferentially performing data replacement on the target cache line corresponding to the second access request which is preferentially replaced according to the replacement priority of the cache line.
4. The method according to claim 1, wherein before changing the replacement priority of the target cache line corresponding to the first access request to priority not to be replaced according to the first block streaming data identifier carried in the first access request, the method further comprises:
adding the first block streaming data identifier to a first access request in a plurality of access requests aiming at streaming data to obtain the first access request;
or, in a plurality of access requests for streaming data, adding the first block streaming data identifier to an access request every other streaming data corresponding to the cache line size to obtain the first access request.
5. The method according to claim 3, wherein before changing the replacement priority of the target cache line corresponding to the second access request to the priority replacement according to the last block of streaming data identifier carried in the second access request, the method further comprises:
adding the last block of streaming data identification to the last access request in a plurality of access requests aiming at streaming data to obtain a second access request;
or, in a plurality of access requests for the streaming data, adding the last block of streaming data identifier to the access request every other streaming data corresponding to the size of the cache line, so as to obtain the second access request.
6. The method according to any one of claims 1 to 5, wherein the replacement priority comprises priority replacement, normal replacement, priority no replacement, and when a cache line needs to be replaced with data, the priority data replacement of the cache line other than the target cache line which is not replaced with priority according to the replacement priority of the cache line comprises:
receiving a data replacement request;
if the cache line with the replacement priority as the priority for replacement exists, randomly selecting one cache line with the priority for replacement to perform data replacement;
if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement exists, selecting one cache line with the normal replacement for data replacement;
and if the cache line with the replacement priority as the priority replacement does not exist and the cache line with the replacement priority as the normal replacement does not exist, selecting one cache line from the cache lines except the cache line with the priority replacement and the cache line with the normal replacement for data replacement.
7. The method of any of claims 1 to 5, wherein the replacement priority comprises priority replacement, normal replacement, priority not replacement, the method further comprising:
when the cache is reset or the target cache line is subjected to data replacement, the replacement priority of the target cache line is changed into normal replacement.
8. A data substitution device, comprising:
the first priority changing module is used for changing the replacement priority of a target cache line corresponding to a first access request into priority without replacement according to a first block streaming data identifier carried in the first access request; a target cache line corresponding to the first access request is a cache line where streaming data requested by the first access request is located;
and the first data replacement module is used for preferentially performing data replacement on the cache lines except the target cache line which is not replaced preferentially according to the replacement priority of the cache line when the cache line needs to perform data replacement.
9. The apparatus of claim 8, wherein the first priority changing module comprises:
the target determining submodule is used for determining that the first access request carries a first block streaming data identifier and a target cache line corresponding to the first access request;
the state modification submodule is used for modifying the replacement state bit corresponding to the target cache line into a state value corresponding to the priority not to be replaced; the replacement state bit is used for representing replacement priority, and the storage position of the replacement state bit is in the tag storage corresponding to the target cache line in the cache.
10. The apparatus of claim 8, further comprising:
the second priority changing module is used for changing the replacement priority of the target cache line corresponding to the second access request into priority replacement according to the last block of streaming data identifier carried in the second access request; a target cache line corresponding to the second access request is a cache line where streaming data requested by the second access request is located;
and the second data replacement module is used for preferentially performing data replacement on the target cache line corresponding to the second access request which is preferentially replaced according to the replacement priority of the cache line when the cache line needs to perform data replacement.
11. The apparatus of claim 8, further comprising:
a first identifier adding module, configured to add a first block streaming data identifier to a first access request in multiple access requests for streaming data before changing, according to a first block streaming data identifier carried in a first access request, a replacement priority of a target cache line corresponding to the first access request to a priority without replacement, so as to obtain the first access request;
or, the second identifier adding module is configured to add, to the access request, the first block streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the first access request.
12. The apparatus of claim 10, further comprising:
a third identifier adding module, configured to add, in multiple access requests for streaming data, a last block of streaming data identifier to a last access request before changing, according to a last block of streaming data identifier carried in a second access request, a replacement priority of a target cache line corresponding to the second access request to a priority replacement, so as to obtain the second access request;
or, the fourth identifier adding module is configured to add, to the access request, the last block of streaming data identifier every other streaming data corresponding to the cache line size in the multiple access requests for the streaming data, so as to obtain the second access request.
13. The apparatus according to any one of claims 8 to 12, wherein the replacement priority comprises priority replacement, normal replacement, priority not replacement, and the first data replacement module comprises:
the request receiving submodule is used for receiving a data replacement request;
the first data replacement submodule is used for randomly selecting a cache line with priority replacement for data replacement if the cache line with priority replacement exists;
the second data replacement submodule is used for selecting a normally replaced cache line for data replacement if the cache line with the replacement priority as the priority for replacement does not exist and the cache line with the replacement priority as the normal replacement exists;
and the third data replacement submodule is used for selecting one cache line from the cache lines except the cache lines with the priority replacement and the normal replacement for performing data replacement if the cache line with the priority replacement is absent and the cache line with the normal replacement priority is absent.
14. The apparatus of any of claims 8 to 12, wherein the replacement priority comprises priority replacement, normal replacement, priority not replacement, the apparatus further comprising:
and the third priority changing module is used for changing the replacement priority of the target cache line into normal replacement when the cache is reset or after the target cache line is subjected to data replacement.
15. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 7 when executing a program stored in the memory.
16. A readable storage medium, characterized in that instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the data replacement method according to one or more of method claims 1-7.
CN202210181764.XA 2022-02-25 2022-02-25 Data replacement method and device, electronic equipment and storage medium Pending CN114610656A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210181764.XA CN114610656A (en) 2022-02-25 2022-02-25 Data replacement method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210181764.XA CN114610656A (en) 2022-02-25 2022-02-25 Data replacement method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114610656A true CN114610656A (en) 2022-06-10

Family

ID=81858792

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210181764.XA Pending CN114610656A (en) 2022-02-25 2022-02-25 Data replacement method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114610656A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010300A (en) * 2023-03-24 2023-04-25 摩尔线程智能科技(北京)有限责任公司 GPU (graphics processing Unit) caching method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010300A (en) * 2023-03-24 2023-04-25 摩尔线程智能科技(北京)有限责任公司 GPU (graphics processing Unit) caching method and device, electronic equipment and storage medium
CN116010300B (en) * 2023-03-24 2023-06-13 摩尔线程智能科技(北京)有限责任公司 GPU (graphics processing Unit) caching method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
RU2615682C2 (en) Method, device, server and terminal for visitting web pages
CN109254849B (en) Application program running method and device
CN107291626B (en) Data storage method and device
CN109947671B (en) Address translation method and device, electronic equipment and storage medium
CN107608714B (en) Byte alignment method, device and computer readable storage medium
US11494117B2 (en) Method and system for data processing
CN111246278B (en) Video playing method and device, electronic equipment and storage medium
CN114610656A (en) Data replacement method and device, electronic equipment and storage medium
JP2024521963A (en) Data access method, device and non-transitory computer-readable storage medium
CN111638938B (en) Migration method and device of virtual machine, electronic equipment and storage medium
CN111246303B (en) Video playing method and device, electronic equipment and storage medium
CN110968523A (en) Memory defragmentation method and device
CN107368562B (en) Page display method and device and terminal
CN115016944A (en) Process access method and device and electronic equipment
CN106354657B (en) Register access method, device and system
CN114077461A (en) Application program running method, device, equipment and storage medium
CN114610324A (en) Binary translation method, processor and electronic equipment
CN115687270A (en) Data storage sorting method and device, electronic equipment and storage medium
CN110990357A (en) Data processing method, device and system, electronic equipment and storage medium
CN107665173B (en) Voice storage method, voice reading method and device
EP2940981B1 (en) Method and device for synchronizing photographs
CN111241097B (en) Method for processing object, device for processing object and storage medium
CN117472371B (en) Remote rendering method, device and storage medium
CN113422800B (en) Resource processing method, device, system, electronic equipment and storage medium
CN111625536B (en) Data access method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination