WO2021208489A1 - Data writing method and apparatus, and electronic device - Google Patents

Data writing method and apparatus, and electronic device Download PDF

Info

Publication number
WO2021208489A1
WO2021208489A1 PCT/CN2020/139418 CN2020139418W WO2021208489A1 WO 2021208489 A1 WO2021208489 A1 WO 2021208489A1 CN 2020139418 W CN2020139418 W CN 2020139418W WO 2021208489 A1 WO2021208489 A1 WO 2021208489A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
write
missed
address
written
Prior art date
Application number
PCT/CN2020/139418
Other languages
French (fr)
Chinese (zh)
Inventor
付鹏
Original Assignee
北京磐易科技有限公司
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 北京磐易科技有限公司 filed Critical 北京磐易科技有限公司
Publication of WO2021208489A1 publication Critical patent/WO2021208489A1/en

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/0893Caches characterised by their organisation or structure
    • 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

Definitions

  • the present disclosure relates to the field of computer technology, and in particular to a data writing method, device and electronic equipment.
  • the data writing methods in the cache mainly include write-through and write-back.
  • the write-through always writes data to the main memory during a write operation
  • the write-back method is
  • the write cache misses the data corresponding to the cache address is first read from the main memory to the cache and then the data is written into the cache. Therefore, the data writing methods in the related technology all need to read and write data from the main memory, resulting in low efficiency of data writing.
  • the embodiments of the present disclosure provide a data writing method, device, and electronic equipment to solve the problem of low efficiency of the current data writing method.
  • an embodiment of the present disclosure provides a data writing method, including the following steps:
  • the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time, the missed data is written into the cache memory.
  • the cache memory includes multiple lines of write addresses, and before extracting the missed data of the write operation missed in the data, the method further includes:
  • An indicator corresponding to the write address in each row is generated, and the indicator is used to indicate whether the corresponding write address is the first write data.
  • the missed data is write-only data, including:
  • the write address corresponding to the write operation of the missed data is data of a write-only address, where the write-only address is a write address of the cache memory that meets a preset range.
  • the writing the missed data into a cache memory includes:
  • the missed data is written into a target address, and the indicator corresponding to the target address is switched to correspond to non-first write data, wherein the target address is a write address in the write-only address.
  • the method further includes:
  • the indicator corresponding to the data written for the first time among the indicator flags of the write-only address is switched to corresponding to the data not written for the first time.
  • the method further includes:
  • the method further includes:
  • the instruction mark corresponding to the first write data among the instruction marks of the write-only address is switched to correspond to the non-first write data.
  • embodiments of the present disclosure provide a data writing device, including:
  • the acquisition module is used to acquire the data to be written into the high-speed buffer memory
  • the writing module is configured to write the missed data into the cache memory if the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time.
  • embodiments of the present disclosure provide an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program being executed by the processor When realizing the steps of the data writing method as described in any one of the above.
  • an embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to implement the steps of the data writing method described in any one of the above.
  • the data to be written into the cache memory is obtained; the miss data of the write operation missed in the data is extracted; if the miss data is write-only data and the write operation of the miss data corresponds If data is written to the write address for the first time, the missed data is written to the cache memory.
  • the miss data is write-only data and the write operation of the miss data corresponds If data is written to the write address for the first time, the missed data is written to the cache memory.
  • Figure 1 is a schematic structural diagram of an electronic device in the related art
  • Figure 2 is a diagram of the index directory structure of the cache in the related technology
  • Figure 3 is a schematic diagram of a data write-back operation in related technologies
  • FIG. 5 is a schematic diagram of the structure of an electronic device in an embodiment of the present disclosure.
  • FIG. 6 is a structural diagram of the index directory of the cache in an embodiment of the present disclosure.
  • FIG. 7 is another flowchart of the data writing method provided by an embodiment of the present disclosure.
  • FIG. 8 is another flowchart of the data writing method provided by an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a data writing device in an embodiment of the present disclosure.
  • CPU Central Processing Unit
  • cache high-speed buffer memory
  • main memory Dynamic Random Access Memory, DRAM, referred to as main memory for short
  • Structured electronic equipment in which the CPU, cache, and main memory are sequentially connected in communication.
  • the basic operations of the cache are divided into reading and writing.
  • the write operation mainly includes two types: write-through and write-back.
  • Write-through means that when a cache write hits, the processor writes data to the main memory while writing to the cache; when a cache write misses, it directly writes data to the main memory. In this way, the data in the memory and the data in the cache are synchronized. This method is simple and reliable. However, each write operation to the cache requires a write operation to the main memory, so the main memory bus takes up a large bandwidth and is inefficient. .
  • Write-back refers to when the CPU writes to the cache, it only modifies the contents of the cache without writing it to the main memory immediately, and only writes it back to the main memory when the cache line is swapped out.
  • a cache line is allocated in the cache for the main memory block that contains the writing to be written (the main memory block filled with shadow in the figure), and the cache line is copied to the cache and then modified It is stored locally in the cache. After that, multiple reads and writes to the cache line will hit and be completed quickly in the cache.
  • Each cache line must be configured with a modification bit dirty to reflect whether the line has been modified by the CPU.
  • Figure 3 is a diagram of the index directory structure corresponding to the cache.
  • the tag is used to store the high-order address of the cache and the main memory address mapping
  • the status indicator dirty is used to indicate whether the cache content has been modified by the CPU, and valid indicates the cache line. is it effective.
  • the corresponding cache line data is written back to the slower main memory only when the dirty bit is valid when the cache line needs to be replaced. This method reduces The number of accesses to the main memory improves efficiency, but the cache line still needs to be read from the main memory when the write misses.
  • the embodiment of the present disclosure provides a data writing method.
  • the data writing method includes the following steps:
  • Step 401 Obtain data to be written into the cache memory.
  • Step 402 Extract the missed data of the write operation missed in the data.
  • the write operation data that misses the write operation among the data sent by the CPU to the cache is first obtained, in other words, it is to detect whether the write operation of the cache hits.
  • Finding useful data in the cache is called a write hit.
  • a write miss When there is no data required by the CPU in the cache, it is called a write miss.
  • the specific definition can refer to related technologies, and no further restrictions are made here. .
  • Step 403 If the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time, write the missed data into the cache memory.
  • this write operation is the first write of data at the write address, which will satisfy these requirements.
  • the conditional data is written directly into the cache.
  • the definition of write-only data in this step 403 means that the write address corresponding to the write operation of the data is the data of the write-only address, where the write-only address is the cache The write address of the memory that meets the preset range.
  • a write-only address range (write only region) can be set in the write address included in the cache in advance.
  • the write address of the cache that meets the write-only address range is called a write-only address, and the write operation When the corresponding write address is the write-only address, the data corresponding to the write operation is considered to be write-only data.
  • the range of the write-only address can be increased on the cache port, so as to realize the screening of the write-only address.
  • the CPU only needs to write the value directly, and does not need to care about the value stored in the write address. Therefore, in the process of writing these data, there is no need to access the data initiated to the main memory. Read operation.
  • the cache memory includes multiple lines of write addresses.
  • step 402 Before the above step 402, it further includes:
  • An indicator corresponding to the write address in each row is generated, and the indicator is used to indicate whether the corresponding write address is the first write data.
  • the index directory of the cache shown in Figure 6 further adds the indicator sflag, and each line of write address has an indicator. To indicate whether the row write address is the first write data.
  • the value of the indicator flag is set to 1 if the row is not written for the first time, that is, in this write If the row has written data before the operation, the value of the indicator is set to 0. In this way, by indexing the value of the indicator of the write address, it can be determined whether the write address is the first time data is written.
  • the refresh control of the indicator sflag can be added to the port of the cache, so as to realize the refresh and switch of the indicator sflag.
  • step 403 also includes:
  • the missed data is written into a target address, and the indicator corresponding to the target address is switched to correspond to non-first write data, wherein the target address is a write address in the write-only address.
  • the write address corresponding to one write operation is the time write data, after the data is written to the write address, in order to avoid the subsequent impact when the data is written to the address again, adjust the corresponding indicator mark.
  • the indicator has a value of 1 when it indicates that data is written for the first time, and a value of 0 when it indicates that data is not written for the first time, then the value of the indicator will be cleared to 0 after the data is written for the first time, so as to avoid repetition. An error is indicated when writing.
  • step 403 is only executed during the first write operation for a write address, and will not affect subsequent reads and writes.
  • step 403 it also includes:
  • the indicator mark corresponding to the first write data among the instruction marks of the write-only address is switched to correspond to the non-first write data.
  • all the write-only data here includes the write-only data in the hit data and the write-only data in the non-hit data. That is to say, when the writing operation of all the write-only data is completed, all the remaining indication marks are switched to correspond to the data not written for the first time, so as to avoid affecting the reading and writing of the non-write-only data.
  • the data obtained in the above step 301 also includes the hit data hit by the write operation.
  • the miss data it also includes the data that does not meet the conditions in step 303, that is, the non-write-only data or the miss data in the miss data.
  • the write address corresponding to the write operation in the hit data is not the data where the data is written for the first time.
  • the technical solution of this embodiment may further include after step 303:
  • the missed data is non-write-only data or the write address corresponding to the write operation of the missed data is not the first write data, the missed data is written to the cache memory in a write-back manner .
  • the data is directly written into the cache memory.
  • the other data in the cache line is overwritten as invalid data, and the tag is updated at the same time.
  • the corresponding indicator sflag is switched, and the corresponding The indication flag sflag is switched to indicate that the data is not written for the first time, or it is called the clear indication flag sflag.
  • an embodiment of the present disclosure provides a data writing device 900, including:
  • the obtaining module 901 is used to obtain data to be written into the cache memory
  • the extraction module 902 is configured to extract the missed data of the write operation missed in the data
  • the writing module 903 is configured to write the missed data into the cache memory if the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time.
  • it also includes:
  • the generating module is used to generate an indicator corresponding to the write address in each row, and the indicator is used to indicate whether the corresponding write address is the first write data.
  • the missed data is write-only data, including: data whose write address corresponding to the write operation of the missed data is a write-only address, wherein the write-only address is the data of the cache memory The write address that meets the preset range.
  • the writing module 903 is specifically configured to: write the missed data to the target address, and switch the indicator corresponding to the target address to correspond to the non-first write data, wherein the target The address is the write address in the write-only address.
  • a switching module which is used to switch the indicator corresponding to the first write data among the indicator flags of the write-only address in the indicator flag of the write-only address to the corresponding non-first write data.
  • it further includes a write-back module, configured to extract hit data hit by a write operation in the data to be written, and write the hit data into the cache memory in a write-back manner.
  • a write-back module configured to extract hit data hit by a write operation in the data to be written, and write the hit data into the cache memory in a write-back manner.
  • it further includes a write-back module, which is used to write the missed data if the missed data is non-write-only data or the write address corresponding to the write operation of the missed data is not the first write data Write to the cache memory in a write-back manner.
  • a write-back module which is used to write the missed data if the missed data is non-write-only data or the write address corresponding to the write operation of the missed data is not the first write data Write to the cache memory in a write-back manner.
  • the data writing device 900 of this embodiment can implement all the technical solutions of the foregoing data writing method embodiments, it can at least achieve similar or substantially the same technical effects, which will not be repeated here.
  • the embodiments of the present disclosure also provide an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor.
  • the computer program is executed by the processor, the implementation is as follows: The steps of the data writing method described in any one of the above.
  • the embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the data writing method described in any one of the above are implemented.
  • the division of the various modules of the above device is only a division of logical functions, and may be fully or partially integrated into a physical entity in actual implementation, or may be physically separated.
  • these modules can all be implemented in the form of software called by processing elements; they can also be implemented in the form of hardware; some modules can be implemented in the form of calling software by processing elements, and some of the modules can be implemented in the form of hardware.
  • the determining module may be a separately established processing element, or it may be integrated in a chip of the above-mentioned device for implementation.
  • it may also be stored in the memory of the above-mentioned device in the form of program code, which is determined by a certain processing element of the above-mentioned device.
  • each step of the above method or each of the above modules can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
  • each module, unit, sub-unit or sub-module may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASIC), or one or Multiple microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays (Field Programmable Gate Array, FPGA), etc.
  • ASIC application specific integrated circuit
  • DSP digital signal processor
  • FPGA Field Programmable Gate Array
  • the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes.
  • these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • SOC system-on-a-chip

Abstract

Disclosed are a data writing method and apparatus, and an electronic device. The data writing method comprises the following steps: acquiring data to be written into a cache memory (401); extracting from the data missed data that was missed by a writing operation (402); if the missed data is write-only data and data is written for the first time into a write-in address corresponding to the writing operation for the missed data corresponding, then writing the missed data into the cache memory (403).

Description

数据写入方法、装置和电子设备Data writing method, device and electronic equipment
相关申请的交叉引用Cross-references to related applications
本申请主张在2020年4月17日在中国提交的中国专利申请号No.202010307935.X的优先权,其全部内容通过引用包含于此。This application claims the priority of Chinese Patent Application No. 202010307935.X filed in China on April 17, 2020, the entire content of which is incorporated herein by reference.
技术领域Technical field
本公开涉及计算机技术领域,尤其涉及一种数据写入方法、装置和电子设备。The present disclosure relates to the field of computer technology, and in particular to a data writing method, device and electronic equipment.
背景技术Background technique
一般来说,电子设备的处理器(CPU)和外部主存之间的访问速度存在很大差距,如果高速度的CPU直接访问低速外部主存会因为外部主存的低速率读写降低CPU的执行效率。因此目前主要通过CPU+cache(高速缓冲存储器)+主存的方式解决CPU与外部主存之间的访问速度不匹配的问题。Generally speaking, there is a big gap in the access speed between the processor (CPU) of an electronic device and the external main memory. If a high-speed CPU directly accesses a low-speed external main memory, the low-speed reading and writing of the external main memory will reduce the CPU's performance. effectiveness. Therefore, at present, the problem of the access speed mismatch between the CPU and the external main memory is mainly solved by the way of CPU + cache (high-speed buffer memory) + main memory.
目前cache中的数据写入方法主要包括写通(write-through)和写回(write-back)两种,其中,写通在写操作时总是向主存写入数据,而写回方式在写cache未命中时首先向主存读出cache对应地址数据到cache再将数据写入cache中。因此,相关技术中的数据写入方式都需要从主存读写数据,导致数据写入的效率较低。At present, the data writing methods in the cache mainly include write-through and write-back. Among them, the write-through always writes data to the main memory during a write operation, and the write-back method is When the write cache misses, the data corresponding to the cache address is first read from the main memory to the cache and then the data is written into the cache. Therefore, the data writing methods in the related technology all need to read and write data from the main memory, resulting in low efficiency of data writing.
发明内容Summary of the invention
本公开实施例提供一种数据写入方法、装置和电子设备,以解决目前数据写入方法效率较低的问题。The embodiments of the present disclosure provide a data writing method, device, and electronic equipment to solve the problem of low efficiency of the current data writing method.
为了解决上述技术问题,本公开是这样实现的:In order to solve the above technical problems, the present disclosure is implemented as follows:
第一方面,本公开实施例提供了一种数据写入方法,包括以下步骤:In the first aspect, an embodiment of the present disclosure provides a data writing method, including the following steps:
获取待写入高速缓冲存储器的数据;Acquiring data to be written into the cache memory;
提取所述数据中写操作未命中的未命中数据;Extracting the missed data of the write operation missed in the data;
若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地 址首次写入数据,则将所述未命中数据写入高速缓冲存储器。If the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time, the missed data is written into the cache memory.
可选的,所述高速缓冲存储器包括多行写入地址,所述提取所述数据中写操作未命中的未命中数据之前,还包括:Optionally, the cache memory includes multiple lines of write addresses, and before extracting the missed data of the write operation missed in the data, the method further includes:
生成与每一行所述写入地址对应的指示标识,所述指示标识用于指示相对应的写入地址是否为首次写入数据。An indicator corresponding to the write address in each row is generated, and the indicator is used to indicate whether the corresponding write address is the first write data.
可选的,所述未命中数据为只写数据,包括:Optionally, the missed data is write-only data, including:
所述未命中数据的写操作对应的写入地址为只写地址的数据,其中,所述只写地址为所述高速缓冲存储器的符合预设范围的写入地址。The write address corresponding to the write operation of the missed data is data of a write-only address, where the write-only address is a write address of the cache memory that meets a preset range.
可选的,所述将所述未命中数据写入高速缓冲存储器,包括:Optionally, the writing the missed data into a cache memory includes:
将所述未命中数据写入目标地址,并将所述目标地址对应的指示标识切换为对应非首次写入数据,其中,所述目标地址为所述只写地址中的写入地址。The missed data is written into a target address, and the indicator corresponding to the target address is switched to correspond to non-first write data, wherein the target address is a write address in the write-only address.
可选的,所述将所述未命中数据写入高速缓冲存储器之后,还包括:Optionally, after writing the missed data into the cache memory, the method further includes:
若全部未命中数据的写操作执行完成,则将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据。If the write operation of all the missed data is completed, the indicator corresponding to the data written for the first time among the indicator flags of the write-only address is switched to corresponding to the data not written for the first time.
可选的,所述将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据之后,还包括:Optionally, after switching the indicator corresponding to the data written for the first time among the indicator flags of the write-only address to the data corresponding to the non-first written data, the method further includes:
提取所述待写入数据中的写操作命中的命中数据,并将所述命中数据以写回的方式写入所述高速缓冲存储器。Extracting hit data hit by a write operation in the data to be written, and writing the hit data to the cache memory in a write-back manner.
可选的,所述提取所述数据中写操作未命中的未命中数据之后,还包括:Optionally, after extracting the missed data of the write operation missed in the data, the method further includes:
若全部只写数据的写操作执行完成,则将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据。If all the write operations of the write-only data are completed, the instruction mark corresponding to the first write data among the instruction marks of the write-only address is switched to correspond to the non-first write data.
第二方面,本公开实施例提供了一种数据写入装置,包括:In a second aspect, embodiments of the present disclosure provide a data writing device, including:
获取模块,用于获取待写入高速缓冲存储器的数据;The acquisition module is used to acquire the data to be written into the high-speed buffer memory;
提取模块,用于提取所述数据中写操作未命中的未命中数据;An extraction module for extracting missed data in the data that is missed by a write operation;
写入模块,用于若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。The writing module is configured to write the missed data into the cache memory if the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time.
第三方面,本公开实施例提供了一种电子设备,包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程 序被所述处理器执行时实现如以上任一项所述的数据写入方法的步骤。In a third aspect, embodiments of the present disclosure provide an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program being executed by the processor When realizing the steps of the data writing method as described in any one of the above.
第四方面,本公开实施例提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以上任一项所述的数据写入方法的步骤。In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to implement the steps of the data writing method described in any one of the above.
本公开实施例中,获取待写入高速缓冲存储器的数据;提取所述数据中写操作未命中的未命中数据;若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。这样,通过将未命中、对应的写入地址为首次写入数据且为只写数据的直接写入高速缓冲存储器,而不经过主存,能够减少对于主存的访问次数,从而提高数据写入效率。In the embodiment of the present disclosure, the data to be written into the cache memory is obtained; the miss data of the write operation missed in the data is extracted; if the miss data is write-only data and the write operation of the miss data corresponds If data is written to the write address for the first time, the missed data is written to the cache memory. In this way, by writing the miss, the corresponding write address as the first write data and write-only data directly to the cache memory, without going through the main memory, the number of accesses to the main memory can be reduced, thereby improving the data writing efficient.
附图说明Description of the drawings
为了更清楚地说明本公开实施例的技术方案,下面将对本公开实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the following will briefly introduce the accompanying drawings used in the description of the embodiments of the present disclosure. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained from these drawings without creative labor.
图1是相关技术中一种电子设备的结构示意图;Figure 1 is a schematic structural diagram of an electronic device in the related art;
图2是相关技术中cache的索引目录结构图;Figure 2 is a diagram of the index directory structure of the cache in the related technology;
图3是相关技术中数据写回操作的示意图;Figure 3 is a schematic diagram of a data write-back operation in related technologies;
图4是本公开一实施例提供的数据写入方法的流程图;4 is a flowchart of a data writing method provided by an embodiment of the present disclosure;
图5是本公开一实施例中电子设备的结构示意图;FIG. 5 is a schematic diagram of the structure of an electronic device in an embodiment of the present disclosure;
图6是本公开一实施例中cache的索引目录结构图;FIG. 6 is a structural diagram of the index directory of the cache in an embodiment of the present disclosure;
图7是本公开一实施例提供的数据写入方法的又一流程图;FIG. 7 is another flowchart of the data writing method provided by an embodiment of the present disclosure;
图8是本公开一实施例提供的数据写入方法的又一流程图;FIG. 8 is another flowchart of the data writing method provided by an embodiment of the present disclosure;
图9是本公开一实施例中数据写入装置的结构示意图。FIG. 9 is a schematic structural diagram of a data writing device in an embodiment of the present disclosure.
具体实施方式Detailed ways
下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全 部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present disclosure.
如图1所示,本实施例的技术方案应用于中央处理器(Central Processing Unit,CPU,简称处理器)+高速缓冲存储器(cache)+主存储器(Dynamic Random Access Memory,DRAM,简称为主存)结构的电子设备,其中,CPU、cache和主存依次通信连接。As shown in Figure 1, the technical solution of this embodiment is applied to Central Processing Unit (CPU) + high-speed buffer memory (cache) + main memory (Dynamic Random Access Memory, DRAM, referred to as main memory for short) ) Structured electronic equipment, in which the CPU, cache, and main memory are sequentially connected in communication.
相关技术中,对于cache的基本操作分为读和写。其中,写操作主要包括写通(write-through)和写回(write-back)两种。In related technologies, the basic operations of the cache are divided into reading and writing. Among them, the write operation mainly includes two types: write-through and write-back.
写通(write-through)指的是当cache写命中时,处理器对cache写入的同时,将数据写入到主存中;当cache写未命中时,直接向主存写入数据。这种方式内存的数据和cache中的数据都是同步的,该方法简单、可靠,但是处理每次对cache的写操作都需要对主存执行写操作,因此主存总线带宽占用大,效率低。Write-through means that when a cache write hits, the processor writes data to the main memory while writing to the cache; when a cache write misses, it directly writes data to the main memory. In this way, the data in the memory and the data in the cache are synchronized. This method is simple and reliable. However, each write operation to the cache requires a write operation to the main memory, so the main memory bus takes up a large bandwidth and is inefficient. .
写回(write-back)指的是当CPU对cache写命中时,只修改cache的内容而不立即写入主存,只当该cache行被换出时才写回主存。Write-back refers to when the CPU writes to the cache, it only modifies the contents of the cache without writing it to the main memory immediately, and only writes it back to the main memory when the cache line is swapped out.
如图2所示,当cache写未命中时,为包含欲写字的主存块(图中填充阴影的主存块)在cache分配一个cache行,将该cache行拷贝到cache后对其进行修改并存放于cache本地,此后对该cache行的多次读写都会命中并在cache中快速完成,每个cache行必须配置一个修改位dirty,以反映此行是否被CPU修改过。As shown in Figure 2, when the cache write misses, a cache line is allocated in the cache for the main memory block that contains the writing to be written (the main memory block filled with shadow in the figure), and the cache line is copied to the cache and then modified It is stored locally in the cache. After that, multiple reads and writes to the cache line will hit and be completed quickly in the cache. Each cache line must be configured with a modification bit dirty to reflect whether the line has been modified by the CPU.
请参阅图3,图3为cache对应的索引目录结构图,其中标签tag用于存储cache与主存地址映射的高位地址,状态标识dirty用于表示cache内容是否被CPU修改过,valid表示cache行是否有效。Please refer to Figure 3. Figure 3 is a diagram of the index directory structure corresponding to the cache. The tag is used to store the high-order address of the cache and the main memory address mapping, the status indicator dirty is used to indicate whether the cache content has been modified by the CPU, and valid indicates the cache line. is it effective.
为确保cache数据(cache data)与主存数据(主存data)一致,在cache行需要被替换时dirty位有效时才将对应的cache行数据写回速度较慢的主存,这种方式减少了访问主存的次数从而提高了效率,但当写未命中时仍然需要从主存中读取cache行。上述写通及写回的过程具体可参考相关技术,此处不再赘述。In order to ensure that the cache data (cache data) is consistent with the main memory data (main memory data), the corresponding cache line data is written back to the slower main memory only when the dirty bit is valid when the cache line needs to be replaced. This method reduces The number of accesses to the main memory improves efficiency, but the cache line still needs to be read from the main memory when the write misses. For the above-mentioned write-through and write-back process, please refer to related technologies for details, which will not be repeated here.
本公开实施例提供了一种数据写入方法。The embodiment of the present disclosure provides a data writing method.
如图4所示,在一个实施例中,该数据写入方法包括以下步骤:As shown in FIG. 4, in one embodiment, the data writing method includes the following steps:
步骤401:获取待写入高速缓冲存储器的数据。Step 401: Obtain data to be written into the cache memory.
一般来说,数据由CPU发送至cache以进一步写入cache,其具体过程可参考相关技术,此处不再赘述。Generally speaking, data is sent from the CPU to the cache to be further written into the cache. For the specific process, please refer to related technologies, which will not be repeated here.
步骤402:提取所述数据中写操作未命中的未命中数据。Step 402: Extract the missed data of the write operation missed in the data.
本实施例中,先获取CPU发送至cache中的数据中,写操作未命中的写操作数据,换句话说,也就是检测cache的写操作是否命中。In this embodiment, the write operation data that misses the write operation among the data sent by the CPU to the cache is first obtained, in other words, it is to detect whether the write operation of the cache hits.
在cache中找到有用的数据被称为写命中(write hit),当cache中没有CPU所需的数据称作写未命中(write miss),其具体定义可参考相关技术,此处不做进一步限定。Finding useful data in the cache is called a write hit. When there is no data required by the CPU in the cache, it is called a write miss. The specific definition can refer to related technologies, and no further restrictions are made here. .
步骤403:若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。Step 403: If the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time, write the missed data into the cache memory.
本实施例中进一步确定未命中数据中的只写(write only)数据,且对应的写操作地址在之前未曾写入数据,本次写操作为在该写入地址首次写入数据,将满足这些条件的数据直接写入cache中。In this embodiment, it is further determined that the write only data in the missed data, and the corresponding write operation address has not written data before, this write operation is the first write of data at the write address, which will satisfy these requirements. The conditional data is written directly into the cache.
作为一种可选的具体实施方式,在该步骤403中只写数据的定义为该数据的写操作对应的写入地址为只写地址的数据,其中,所述只写地址为所述高速缓冲存储器的符合预设范围的写入地址。As an optional specific implementation manner, the definition of write-only data in this step 403 means that the write address corresponding to the write operation of the data is the data of the write-only address, where the write-only address is the cache The write address of the memory that meets the preset range.
具体的,可以预先在cache包括的写入地址中设定一个只写地址范围(write only region),本实施例中将cache符合该只写地址范围的写入地址称作只写地址,写操作对应的写入地址为该只写地址时,则认为该写操作对应的数据为只写数据。Specifically, a write-only address range (write only region) can be set in the write address included in the cache in advance. In this embodiment, the write address of the cache that meets the write-only address range is called a write-only address, and the write operation When the corresponding write address is the write-only address, the data corresponding to the write operation is considered to be write-only data.
实施时,如图5所示,可以在cache的端口增加该只写地址的范围,从而实现对只写地址的筛选。During implementation, as shown in Figure 5, the range of the write-only address can be increased on the cache port, so as to realize the screening of the write-only address.
对于满足上述条件的数据在处理过程中,CPU只需要将值直接写入,不需要关心该写入地址曾经储存的值,因此在写入这些数据的过程中,不需要访问向主存发起的读操作。For the data that meets the above conditions in the process of processing, the CPU only needs to write the value directly, and does not need to care about the value stored in the write address. Therefore, in the process of writing these data, there is no need to access the data initiated to the main memory. Read operation.
这样,通过将未命中、对应的写入地址为首次写入数据且为只写数据的直接写入高速缓冲存储器,而不经过主存,能够减少对于主存的访问次数, 从而提高数据写入效率。In this way, by writing the miss, the corresponding write address as the first write data and write-only data directly to the cache memory, without passing through the main memory, the number of accesses to the main memory can be reduced, thereby improving the data writing efficient.
可选的,在一个具体实施方式中,高速缓冲存储器包括多行写入地址。Optionally, in a specific implementation, the cache memory includes multiple lines of write addresses.
在上述步骤402之前,还包括:Before the above step 402, it further includes:
生成与每一行所述写入地址对应的指示标识,所述指示标识用于指示相对应的写入地址是否为首次写入数据。An indicator corresponding to the write address in each row is generated, and the indicator is used to indicate whether the corresponding write address is the first write data.
请同时参阅图3和图6,区别于图3所示的相关技术,图6所示的cache的索引目录进一步增加了指示标识sflag,每一行写入地址具有一个指示标识,该指示标识通过不同的值来指示该行写入地址是否为首次写入数据。Please refer to Figure 3 and Figure 6 at the same time. Different from the related technology shown in Figure 3, the index directory of the cache shown in Figure 6 further adds the indicator sflag, and each line of write address has an indicator. To indicate whether the row write address is the first write data.
例如,如果该行为首次写入数据,即在本次写操作之前,该行未曾写入数据,则将该指示标识的值设置为1,如果该行非首次写入数据,即在本次写操作之前该行曾经写入过数据,则将该指示标识的值设置为0,这样,通过对写入地址的指示标识的值进行索引,能够确定该写入地址是否为首次写入数据。For example, if the row writes data for the first time, that is, before this write operation, the row has not written data, the value of the indicator flag is set to 1, if the row is not written for the first time, that is, in this write If the row has written data before the operation, the value of the indicator is set to 0. In this way, by indexing the value of the indicator of the write address, it can be determined whether the write address is the first time data is written.
如图5所示,实施时,可以在cache的端口增加该指示标识sflag的刷新控制,从而实现对于指示标识sflag的刷新和切换。As shown in Figure 5, during implementation, the refresh control of the indicator sflag can be added to the port of the cache, so as to realize the refresh and switch of the indicator sflag.
进一步的,上述步骤403还包括:Further, the above step 403 also includes:
将所述未命中数据写入目标地址,并将所述目标地址对应的指示标识切换为对应非首次写入数据,其中,所述目标地址为所述只写地址中的写入地址。The missed data is written into a target address, and the indicator corresponding to the target address is switched to correspond to non-first write data, wherein the target address is a write address in the write-only address.
如果一次写操作对应的写入地址为时候次写入数据,则在将数据写入该写入地址后,为了避免后续再次在该地址写入数据时造成影响,调整相应的指示标识。If the write address corresponding to one write operation is the time write data, after the data is written to the write address, in order to avoid the subsequent impact when the data is written to the address again, adjust the corresponding indicator mark.
例如,如果指示标识在指示首次写入数据的情况下值为1,指示非首次写入数据的情况下值为0,那么在首次写入数据后,将指示标识的值清0,从而避免再次写入时指示错误。For example, if the indicator has a value of 1 when it indicates that data is written for the first time, and a value of 0 when it indicates that data is not written for the first time, then the value of the indicator will be cleared to 0 after the data is written for the first time, so as to avoid repetition. An error is indicated when writing.
也就是说,上述步骤403只有在针对一个写入地址的第一次写操作时执行,不会对后续的读写造成影响。That is to say, the above step 403 is only executed during the first write operation for a write address, and will not affect subsequent reads and writes.
进一步的,在步骤403之后,还包括:Further, after step 403, it also includes:
若全部只写数据的写操作执行完成,则将所述只写地址的指示标识中, 对应首次写入数据的指示标识切换为对应非首次写入数据。If all the write operations of the write-only data are completed, the indicator mark corresponding to the first write data among the instruction marks of the write-only address is switched to correspond to the non-first write data.
应当理解的是,此处的全部只写数据包括了命中数据中的只写数据和非命中数据中的只写数据。也就是说,当全部只写数据的写操作执行完毕后,将剩余的指示标识全部切换为对应非首次写入数据,从而避免对非只写数据的读写造成影响。It should be understood that all the write-only data here includes the write-only data in the hit data and the write-only data in the non-hit data. That is to say, when the writing operation of all the write-only data is completed, all the remaining indication marks are switched to correspond to the data not written for the first time, so as to avoid affecting the reading and writing of the non-write-only data.
显然,上述步骤301中获取的数据还包括写操作命中的命中数据,此外,对于未命中数据来说,还包括不符合步骤303中条件的数据,即未命中数据中的非只写数据或未命中数据中的写操作对应的写入地址非首次写入数据的数据。Obviously, the data obtained in the above step 301 also includes the hit data hit by the write operation. In addition, for the miss data, it also includes the data that does not meet the conditions in step 303, that is, the non-write-only data or the miss data in the miss data. The write address corresponding to the write operation in the hit data is not the data where the data is written for the first time.
这些数据同样需要写入cache中,为了避免这些数据丢失,进一步的,本实施例的技术方案在步骤303之后还可以包括:These data also need to be written into the cache. In order to avoid the loss of these data, further, the technical solution of this embodiment may further include after step 303:
提取所述待写入数据中的写操作命中的命中数据,并将所述命中数据以写回的方式写入所述高速缓冲存储器;以及Extracting hit data hit by a write operation in the data to be written, and writing the hit data to the cache memory in a write-back manner; and
若所述未命中数据为非只写数据或所述未命中数据的写操作对应的写入地址非首次写入数据,则将所述未命中数据以写回的方式写入所述高速缓冲存储器。If the missed data is non-write-only data or the write address corresponding to the write operation of the missed data is not the first write data, the missed data is written to the cache memory in a write-back manner .
这样,通过将其余的数据以写回的方式写入高速缓冲存储器,能够避免数据丢失,确保全部数据写入高速缓冲存储器中。In this way, by writing the remaining data into the cache memory in a write-back manner, it is possible to avoid data loss and ensure that all data is written into the cache memory.
请同时参阅图7和图8,本实施例的技术方案可以概括如下。Please refer to FIG. 7 and FIG. 8 at the same time. The technical solution of this embodiment can be summarized as follows.
首先,置位全部sflag,也就是刷新全部指示标识sflag为对应首次写入数据。First, all sflags are set, that is, the refresh all indication flag sflag corresponds to the first write data.
接下来,检测CPU执行的操作是否为写操作,如果CPU执行的操作为读操作,则以常规的写回的方式执行,具体可参考相关技术。Next, it is checked whether the operation performed by the CPU is a write operation. If the operation performed by the CPU is a read operation, it is executed in a conventional write-back manner. For details, refer to related technologies.
进一步的,检测cache写操作是否未命中、写操作对应的写入地址是否属于预设只写地址、写操作对应的写入地址的指示标识sflag是否为1,也就是指示标识sflag是否指示首次写入数据。Further, detect whether the cache write operation is missed, whether the write address corresponding to the write operation belongs to a preset write-only address, and whether the indicator sflag of the write address corresponding to the write operation is 1, that is, whether the indicator sflag indicates the first write Into the data.
如果数据同时满足上述全部条件,则将数据直接写入高速缓冲存储器cache,此时,cache行的其它数据被覆盖为无效数据,同时更新标签tag,同时,切换对应的指示标识sflag,将对应的指示标识sflag切换为指示非首 次写入数据,或称清零指示标识sflag。If the data satisfies all the above conditions at the same time, the data is directly written into the cache memory. At this time, the other data in the cache line is overwritten as invalid data, and the tag is updated at the same time. At the same time, the corresponding indicator sflag is switched, and the corresponding The indication flag sflag is switched to indicate that the data is not written for the first time, or it is called the clear indication flag sflag.
当全部只写数据的写操作完成后,或称全部只写操作完成后,将剩余的全部指示标识sflag清0,以避免对非只写数据造成影响。When the write operation of all write-only data is completed, or all the write-only operations are completed, all the remaining indication flags sflag are cleared to 0 to avoid affecting the non-write-only data.
这样请同时参阅图2和图7,与图2所示的相关技术相比,本实施例的技术方案不涉及到对主存中的读操作,因此,本实施例的技术方案可以减少cache向主存的读次数,提高主存带宽使用效率。In this way, please refer to Figure 2 and Figure 7 at the same time. Compared with the related technology shown in Figure 2, the technical solution of this embodiment does not involve the read operation in the main memory. Therefore, the technical solution of this embodiment can reduce the cache direction. The number of reads of the main memory improves the efficiency of the main memory bandwidth usage.
如图9所示,本公开实施例提供了一种数据写入装置900,包括:As shown in FIG. 9, an embodiment of the present disclosure provides a data writing device 900, including:
获取模块901,用于获取待写入高速缓冲存储器的数据;The obtaining module 901 is used to obtain data to be written into the cache memory;
提取模块902,用于提取所述数据中写操作未命中的未命中数据;The extraction module 902 is configured to extract the missed data of the write operation missed in the data;
写入模块903,用于若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。The writing module 903 is configured to write the missed data into the cache memory if the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time.
可选的,还包括:Optionally, it also includes:
生成模块,用于生成与每一行所述写入地址对应的指示标识,所述指示标识用于指示相对应的写入地址是否为首次写入数据。The generating module is used to generate an indicator corresponding to the write address in each row, and the indicator is used to indicate whether the corresponding write address is the first write data.
可选的,所述未命中数据为只写数据,包括:所述未命中数据的写操作对应的写入地址为只写地址的数据,其中,所述只写地址为所述高速缓冲存储器的符合预设范围的写入地址。Optionally, the missed data is write-only data, including: data whose write address corresponding to the write operation of the missed data is a write-only address, wherein the write-only address is the data of the cache memory The write address that meets the preset range.
可选的,所述写入模块903,具体用于:将所述未命中数据写入目标地址,并将所述目标地址对应的指示标识切换为对应非首次写入数据,其中,所述目标地址为所述只写地址中的写入地址。Optionally, the writing module 903 is specifically configured to: write the missed data to the target address, and switch the indicator corresponding to the target address to correspond to the non-first write data, wherein the target The address is the write address in the write-only address.
可选的,还包括:切换模块,用于若全部只写数据的写操作执行完成,则将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据。Optionally, it further includes: a switching module, which is used to switch the indicator corresponding to the first write data among the indicator flags of the write-only address in the indicator flag of the write-only address to the corresponding non-first write data.
可选的,还包括写回模块,用于提取所述待写入数据中的写操作命中的命中数据,并将所述命中数据以写回的方式写入所述高速缓冲存储器。Optionally, it further includes a write-back module, configured to extract hit data hit by a write operation in the data to be written, and write the hit data into the cache memory in a write-back manner.
可选的,还包括写回模块,用于若所述未命中数据为非只写数据或所述未命中数据的写操作对应的写入地址非首次写入数据,则将所述未命中数据以写回的方式写入所述高速缓冲存储器。Optionally, it further includes a write-back module, which is used to write the missed data if the missed data is non-write-only data or the write address corresponding to the write operation of the missed data is not the first write data Write to the cache memory in a write-back manner.
由于本实施例的数据写入装置900能够实现上述数据写入方法实施例的全部技术方案,因此至少能实现相近或基本相同的技术效果,此处不再赘述。Since the data writing device 900 of this embodiment can implement all the technical solutions of the foregoing data writing method embodiments, it can at least achieve similar or substantially the same technical effects, which will not be repeated here.
本公开实施例还提供了一种电子设备,包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如以上任一项所述的数据写入方法的步骤。The embodiments of the present disclosure also provide an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, the implementation is as follows: The steps of the data writing method described in any one of the above.
本公开实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以上任一项所述的数据写入方法的步骤。The embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the data writing method described in any one of the above are implemented.
需要说明的是,应理解以上设备的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些模块可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分模块通过处理元件调用软件的形式实现,部分模块通过硬件的形式实现。例如,确定模块可以为单独设立的处理元件,也可以集成在上述装置的某一个芯片中实现,此外,也可以以程序代码的形式存储于上述装置的存储器中,由上述装置的某一个处理元件调用并执行以上确定模块的功能。其它模块的实现与之类似。此外这些模块全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件可以是一种集成电路,具有信号的处理能力。在实现过程中,上述方法的各步骤或以上各个模块可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions, and may be fully or partially integrated into a physical entity in actual implementation, or may be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be implemented in the form of hardware; some modules can be implemented in the form of calling software by processing elements, and some of the modules can be implemented in the form of hardware. For example, the determining module may be a separately established processing element, or it may be integrated in a chip of the above-mentioned device for implementation. In addition, it may also be stored in the memory of the above-mentioned device in the form of program code, which is determined by a certain processing element of the above-mentioned device. Call and execute the functions of the above-identified module. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together or implemented independently. The processing element described here may be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each of the above modules can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
例如,各个模块、单元、子单元或子模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit,ASIC),或,一个或多个微处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array,FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(Central Processing Unit,CPU)或其它可以调用程序代码的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。For example, each module, unit, sub-unit or sub-module may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASIC), or one or Multiple microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays (Field Programmable Gate Array, FPGA), etc. For another example, when one of the above modules is implemented in the form of processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数 据在适当情况下可以互换,以便这里描述的本申请的实施例,例如除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。此外,说明书以及权利要求中使用“和/或”表示所连接对象的至少其中之一,例如A和/或B和/或C,表示包含单独A,单独B,单独C,以及A和B都存在,B和C都存在,A和C都存在,以及A、B和C都存在的7种情况。类似地,本说明书以及权利要求中使用“A和B中的至少一个”应理解为“单独A,单独B,或A和B都存在”。The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described herein, for example, can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations of them are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those clearly listed. Those steps or units may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or equipment. In addition, the use of "and/or" in the description and claims means at least one of the connected objects, such as A and/or B and/or C, which means that it includes A alone, B alone, C alone, and both A and B. Exist, B and C exist, A and C exist, and A, B, and C all exist in 7 situations. Similarly, the use of "at least one of A and B" in this specification and claims should be understood as "A alone, B alone, or both A and B exist".
以上所述,仅为本公开的具体实施方式,但本公开的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应以权利要求的保护范围为准。The above are only specific implementations of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present disclosure. It should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims (10)

  1. 一种数据写入方法,包括以下步骤:A data writing method includes the following steps:
    获取待写入高速缓冲存储器的数据;Acquiring data to be written into the cache memory;
    提取所述数据中写操作未命中的未命中数据;Extracting the missed data of the write operation missed in the data;
    若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。If the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time, the missed data is written into the cache memory.
  2. 如权利要求1所述的数据写入方法,其中,所述高速缓冲存储器包括多行写入地址,所述提取所述数据中写操作未命中的未命中数据之前,还包括:5. The data writing method according to claim 1, wherein the cache memory includes multiple lines of write addresses, and before extracting the missed data of the write operation missed in the data, the method further comprises:
    生成与每一行所述写入地址对应的指示标识,所述指示标识用于指示相对应的写入地址是否为首次写入数据。An indicator corresponding to the write address in each row is generated, and the indicator is used to indicate whether the corresponding write address is the first write data.
  3. 如权利要求2所述的数据写入方法,其中,所述未命中数据为只写数据,包括:3. The data writing method of claim 2, wherein the missed data is write-only data, including:
    所述未命中数据的写操作对应的写入地址为只写地址的数据,其中,所述只写地址为所述高速缓冲存储器的符合预设范围的写入地址。The write address corresponding to the write operation of the missed data is data of a write-only address, where the write-only address is a write address of the cache memory that meets a preset range.
  4. 如权利要求3所述的数据写入方法,其中,所述将所述未命中数据写入高速缓冲存储器,包括:5. The data writing method according to claim 3, wherein the writing the missed data to a cache memory comprises:
    将所述未命中数据写入目标地址,并将所述目标地址对应的指示标识切换为对应非首次写入数据,其中,所述目标地址为所述只写地址中的写入地址。The missed data is written into a target address, and the indicator corresponding to the target address is switched to correspond to non-first write data, wherein the target address is a write address in the write-only address.
  5. 如权利要求4所述的数据写入方法,其中,所述将所述未命中数据写入高速缓冲存储器之后,还包括:5. The data writing method according to claim 4, wherein after writing the missed data into a cache memory, the method further comprises:
    若全部未命中数据的写操作执行完成,则将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据。If the write operation of all the missed data is completed, the indicator corresponding to the data written for the first time among the indicator flags of the write-only address is switched to corresponding to the data not written for the first time.
  6. 如权利要求5所述的数据写入方法,其中,所述将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据之后,还包括:5. The data writing method according to claim 5, wherein after switching the indicator corresponding to the data written for the first time among the indicator flags of the write-only address to the data corresponding to the non-first write data, the method further comprises:
    提取所述待写入数据中的写操作命中的命中数据,并将所述命中数据以 写回的方式写入所述高速缓冲存储器。The hit data hit by the write operation in the data to be written is extracted, and the hit data is written into the cache memory in a write-back manner.
  7. 如权利要求1至6中任一项所述的数据写入方法,其中,所述提取所述数据中写操作未命中的未命中数据之后,还包括:The data writing method according to any one of claims 1 to 6, wherein after said extracting the missed data of the write operation missed in the data, the method further comprises:
    若全部只写数据的写操作执行完成,则将所述只写地址的指示标识中,对应首次写入数据的指示标识切换为对应非首次写入数据。If all the write operations of the write-only data are completed, the instruction mark corresponding to the first write data among the instruction marks of the write-only address is switched to correspond to the non-first write data.
  8. 一种数据写入装置,包括:A data writing device includes:
    获取模块,用于获取待写入高速缓冲存储器的数据;The acquisition module is used to acquire the data to be written into the high-speed buffer memory;
    提取模块,用于提取所述数据中写操作未命中的未命中数据;An extraction module for extracting missed data in the data that is missed by a write operation;
    写入模块,用于若所述未命中数据为只写数据且所述未命中数据的写操作对应的写入地址首次写入数据,则将所述未命中数据写入高速缓冲存储器。The writing module is configured to write the missed data into the cache memory if the missed data is write-only data and the write address corresponding to the write operation of the missed data writes data for the first time.
  9. 一种电子设备,包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如权利要求1至7中任一项所述的数据写入方法的步骤。An electronic device comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program being executed by the processor to implement any of claims 1 to 7 One of the steps of the data writing method.
  10. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现权利要求1至7中任一项所述的数据写入方法的步骤。A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the data writing method according to any one of claims 1 to 7 when the computer program is executed by a processor.
PCT/CN2020/139418 2020-04-17 2020-12-25 Data writing method and apparatus, and electronic device WO2021208489A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010307935.X 2020-04-17
CN202010307935.XA CN111831587A (en) 2020-04-17 2020-04-17 Data writing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
WO2021208489A1 true WO2021208489A1 (en) 2021-10-21

Family

ID=72913647

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/139418 WO2021208489A1 (en) 2020-04-17 2020-12-25 Data writing method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN111831587A (en)
WO (1) WO2021208489A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115061972A (en) * 2022-07-05 2022-09-16 摩尔线程智能科技(北京)有限责任公司 Processor, data read-write method, device and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111831587A (en) * 2020-04-17 2020-10-27 北京奕斯伟计算技术有限公司 Data writing method and device and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902631A (en) * 2012-09-18 2013-01-30 杭州中天微系统有限公司 Multiprocessor inter-core transmission method for avoiding data back writing during read-miss
CN104050095A (en) * 2013-03-14 2014-09-17 索尼公司 Cache Control Device, Processor, Information Processing System, And Cache Control Method
US20150378911A1 (en) * 2014-06-27 2015-12-31 International Business Machines Corporation Allowing non-cacheable loads within a transaction
CN108604210A (en) * 2016-03-01 2018-09-28 高通股份有限公司 Distribution is write based on the cache for executing license
US20190004957A1 (en) * 2016-06-29 2019-01-03 EMC IP Holding Company LLC Low-overhead index for a flash cache
CN110119248A (en) * 2016-12-05 2019-08-13 华为技术有限公司 Control method, storage equipment and the system of reading and writing data order
CN111831587A (en) * 2020-04-17 2020-10-27 北京奕斯伟计算技术有限公司 Data writing method and device and electronic equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100370440C (en) * 2005-12-13 2008-02-20 华为技术有限公司 Processor system and its data operating method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902631A (en) * 2012-09-18 2013-01-30 杭州中天微系统有限公司 Multiprocessor inter-core transmission method for avoiding data back writing during read-miss
CN104050095A (en) * 2013-03-14 2014-09-17 索尼公司 Cache Control Device, Processor, Information Processing System, And Cache Control Method
US20150378911A1 (en) * 2014-06-27 2015-12-31 International Business Machines Corporation Allowing non-cacheable loads within a transaction
CN108604210A (en) * 2016-03-01 2018-09-28 高通股份有限公司 Distribution is write based on the cache for executing license
US20190004957A1 (en) * 2016-06-29 2019-01-03 EMC IP Holding Company LLC Low-overhead index for a flash cache
CN110119248A (en) * 2016-12-05 2019-08-13 华为技术有限公司 Control method, storage equipment and the system of reading and writing data order
CN111831587A (en) * 2020-04-17 2020-10-27 北京奕斯伟计算技术有限公司 Data writing method and device and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115061972A (en) * 2022-07-05 2022-09-16 摩尔线程智能科技(北京)有限责任公司 Processor, data read-write method, device and storage medium
CN115061972B (en) * 2022-07-05 2023-10-13 摩尔线程智能科技(北京)有限责任公司 Processor, data read-write method, device and storage medium

Also Published As

Publication number Publication date
CN111831587A (en) 2020-10-27

Similar Documents

Publication Publication Date Title
US11789872B2 (en) Slot/sub-slot prefetch architecture for multiple memory requestors
US8037281B2 (en) Miss-under-miss processing and cache flushing
TWI531912B (en) Processor having translation lookaside buffer for multiple context comnpute engine, system and method for enabling threads to access a resource in a processor
US9292447B2 (en) Data cache prefetch controller
US8504794B1 (en) Override system and method for memory access management
US8601235B2 (en) System and method for concurrently managing memory access requests
US20100161923A1 (en) Method and apparatus for reallocating memory content
US20100325374A1 (en) Dynamically configuring memory interleaving for locality and performance isolation
WO2021208489A1 (en) Data writing method and apparatus, and electronic device
US20120272011A1 (en) Processor cache tracing
WO2018119773A1 (en) Non-volatile memory access method, device, and system
US9003130B2 (en) Multi-core processing device with invalidation cache tags and methods
CN112506823B (en) FPGA data reading and writing method, device, equipment and readable storage medium
US8706975B1 (en) Memory access management block bind system and method
US20080065855A1 (en) DMAC Address Translation Miss Handling Mechanism
US8650380B2 (en) Processor and arithmatic operation method
US20230114242A1 (en) Data processing method and apparatus and heterogeneous system
CN116303138A (en) Caching architecture, caching method and electronic equipment
US10146698B2 (en) Method and apparatus for power reduction in a multi-threaded mode
CN110737407A (en) data buffer memory realizing method supporting mixed writing strategy
KR20210037216A (en) Memory management unit capable of managing address translation table using heterogeneous memory, and address management method thereof
US10241906B1 (en) Memory subsystem to augment physical memory of a computing system
US20130173862A1 (en) Method for cleaning cache of processor and associated processor
US11847074B2 (en) Input/output device operational modes for a system with memory pools
TWI786476B (en) Processing and storage circuit

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20931575

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20931575

Country of ref document: EP

Kind code of ref document: A1