WO2016070431A1 - Memory access method and apparatus, and computer device - Google Patents

Memory access method and apparatus, and computer device Download PDF

Info

Publication number
WO2016070431A1
WO2016070431A1 PCT/CN2014/090649 CN2014090649W WO2016070431A1 WO 2016070431 A1 WO2016070431 A1 WO 2016070431A1 CN 2014090649 W CN2014090649 W CN 2014090649W WO 2016070431 A1 WO2016070431 A1 WO 2016070431A1
Authority
WO
WIPO (PCT)
Prior art keywords
read
word
words
memory
cache device
Prior art date
Application number
PCT/CN2014/090649
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 华为技术有限公司
Priority to CN201480038252.1A priority Critical patent/CN105900060B/en
Priority to PCT/CN2014/090649 priority patent/WO2016070431A1/en
Publication of WO2016070431A1 publication Critical patent/WO2016070431A1/en

Links

Images

Definitions

  • the embodiments of the present invention relate to the field of computer technologies, and in particular, to a memory access method, apparatus, and computer device.
  • the data that the processor needs to use is generally stored in the memory.
  • the processor needs to obtain data from the memory and store it in the cache for use.
  • the data acquired by the processor is obtained in units of words (English: word).
  • a read instruction for the data is sent to the cache, and the read instruction is used to acquire a word required by the processor, that is, a keyword; if the data is found, The data is returned to the processor; if the data is not found in the cache, the read instruction is forwarded to the memory by the cache, and the memory returns the memory line to which the keyword belongs to the cache according to the read instruction, so as to A cache line is formed in the cache (English: cacheline).
  • a memory line can include 8 words, for example, 8 words including 0, 1, 2, 3, 4, 5, 6, and 7.
  • the memory lines are returned to the cache in the order of the sixth, seventh, first, second, third, fourth, and fifth words, that is, the keywords required for the read instruction are preferentially returned inside the memory line, and the words other than the keywords in the cache line are deleted. It is called a prefetch word; then the cache returns the keyword to the processor.
  • the memory needs to return all the words in one memory line corresponding to one read instruction to the cache, and the memory can return another cache to the cache according to another read instruction.
  • Embodiments of the present invention provide a memory access method, apparatus, and computer apparatus for reducing a read delay of a word required by a processor.
  • an embodiment of the present invention provides a memory access method, including:
  • the cache device receives N read commands sent by the processor, where N is an integer greater than or equal to 2,
  • Each of the read commands includes an address of a word to be read, the address of the word to be read includes an address of a memory line to which the word to be read belongs, and an address of the word to be read in the memory line, the read command For reading the word to be read;
  • the cache device forwards the N read commands to the memory controller;
  • the cache device receives the N to-be-sent words sent by the memory controller, and sends the N to-be-read words to the processor;
  • the cache device receives other words in the memory row to which the N words to be read are sent by the memory controller, except the N to-be-read words.
  • the receiving, by the cache device, the first word sent by the memory controller includes:
  • the method further includes:
  • the cache device caches the first word according to a priority of the first word from high to low;
  • the first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
  • an embodiment of the present invention provides a memory access method, including:
  • the memory controller receives N read commands sent by the cache device, the N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the word to be read An address of the associated memory line and an address of the word to be read in the memory line, the read command is used to read the word to be read;
  • the memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the address of the N words to be read, and sends the N to be read to the cache device. word;
  • the memory controller acquires words other than the N to-be-read words from the memory lines to which the N words to be read belong, and sends the other words to the cache device.
  • the memory controller sends the other words to the cache device, including:
  • the memory controller belongs to the same memory particle according to the memory line to which the N words to be read belong
  • the other words are transmitted to the cache device in descending order of priority of the words other than the N words to be read.
  • the memory controller sends the first word to the cache device, including:
  • the memory controller sends a priority of the first word and the first word to the cache device, where the first word is the N words to be read or the N words to be read belong to A word other than the N words to be read in the memory line.
  • the method before the sending, by the memory controller, the first word to the cache device, the method further includes:
  • the memory controller determines the priority of each word according to the read/write frequency of each word in the memory line to which the N words to be read belong.
  • the memory lines of the N to-be-read words belong to Each word in it is stored in a memory particle.
  • an embodiment of the present invention provides a cache device, including:
  • a receiving unit configured to receive N read commands sent by the processor, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
  • a processing unit configured to determine whether the N to-be-read words are cached in the cache device
  • a sending unit configured to: when the processing unit determines that the N to-be-read words are not cached in the cache device, forward the N read commands to a memory controller;
  • the receiving unit is further configured to receive the N to-be-sent words sent by the memory controller, and
  • the sending unit is further configured to send the N to-be-read words to the processor;
  • the receiving unit is further configured to receive, in the memory row to which the N to-be-read words are sent by the memory controller, other words than the N to-be-read words.
  • the receiving unit is configured to receive the first word sent by the memory controller, where: the receiving unit is configured to receive, by the memory controller, Describe the priority of the first word and the first word;
  • the processing unit is further configured to cache the first word according to a priority of the first word from high to low;
  • the first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
  • an embodiment of the present invention provides a memory controller, including:
  • a receiving unit configured to receive N read commands sent by the cache device, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
  • a processing unit configured to acquire the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words;
  • a sending unit configured to send the N to-be-read words to the cache device
  • the processing unit is further configured to obtain, from the memory lines to which the N to-be-read words belong, words other than the N to-be-read words;
  • the sending unit is further configured to send the other words to the cache device.
  • the sending unit is configured to send the other words to the cache device, where: the sending unit is configured to: according to the memory line to which the N to-be-read words belong The other words belonging to the same memory particle in a descending order of priority of each of the N words to be read are sent to the cache device.
  • the sending unit is configured to send the first word to the cache device, including: The sending unit is configured to send a priority of the first word and the first word to the cache device, where the first word is the N words to be read or the N words to be read A word other than the N words to be read in the associated memory line.
  • the processing unit is further configured to send, by the sending unit, the first to the cache device Before the word, the priority of each word is determined according to the frequency of reading and writing of each word in the memory line to which the N words to be read belong.
  • the memory lines of the N to-be-read words belong to Medium Each word is stored in a memory granule.
  • the embodiment of the present invention provides a computer device, including: a cache device provided by the third aspect of the embodiment or the first possible implementation manner of the third aspect, the fourth aspect or the fourth embodiment of the present invention
  • Various possible implementations of aspects provide memory controllers, processors, and memory devices.
  • the memory access method, device, and computer device provided by the embodiment of the present invention receive at least two read commands sent by the processor through the cache device, and when the N to-be-read words are not cached in the cache device, the memory controller is Forwarding the at least two read commands, receiving the N to-be-read words sent by the memory controller, and sending the N to-be-read words to the processor, and then receiving the location sent by the memory controller
  • the words other than the N to-be-read words in the memory line to which the N words to be read belong are described.
  • the cache device Since the cache device does not need to acquire other words in the memory row to which the N words to be read belong in the process of acquiring the N words to be read, the delay of reading the N words to be read is not increased, and the existing Compared with the technology, the read delay of the word to be read can be reduced.
  • Embodiment 1 is a flowchart of Embodiment 1 of a memory access method according to the present invention
  • Embodiment 2 is a flowchart of Embodiment 2 of a memory access method according to the present invention
  • Embodiment 3 is a flowchart of Embodiment 3 of a memory access method according to the present invention.
  • FIG. 4 is a schematic diagram of accessing a word to be read according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a memory line according to an embodiment of the present invention.
  • FIG. 6 is a flowchart of Embodiment 4 of a memory access method according to the present invention.
  • FIG. 7 is a schematic diagram of access to be written according to an embodiment of the present invention.
  • Embodiment 8 is a flowchart of Embodiment 5 of a memory access method according to the present invention.
  • FIG. 9 is a schematic diagram of accessing a word to be read according to an embodiment of the present invention.
  • Embodiment 1 of a cache device is a schematic structural diagram of Embodiment 1 of a cache device according to the present invention.
  • Embodiment 1 is a schematic structural diagram of Embodiment 1 of a memory controller according to the present invention.
  • FIG. 12 is a schematic structural diagram of Embodiment 1 of a computer device according to the present invention.
  • Embodiment 1 is a flowchart of Embodiment 1 of a memory access method according to the present invention. As shown in FIG. 1, the method in this embodiment may include:
  • the cache device receives N read commands sent by the processor, where N is an integer greater than or equal to 2.
  • Each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read The address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read.
  • the cache device may receive N read commands sent by one processor core of the processor, or the cache device may receive N read commands sent by multiple processor cores of the processor, among the N read commands.
  • Each of the read commands includes an address of the word to be read, wherein the address of the word to be read included in each read command may be different, and the address of the word to be read includes the address of the memory line to which the word to be read belongs and the word to be read is The address in the associated memory line, each read command is used to read the word to be read corresponding to the address included in the read command.
  • the cache device forwards the N read commands to the memory controller.
  • the cache device may determine, according to the addresses of the N words to be read, whether the N words to be read have been cached. If the N words to be read are cached in the cache device, the cache device substitutes the N. The words to be read are sent to the processor, that is, the N words are stored in corresponding registers in the processor. If the N words to be read are not cached in the cache device, that is, the cache miss, the cache device needs to be The N words to be read are obtained in the memory, and the cache device sends the N read commands to the memory controller.
  • the cache device receives the N to-be-sent words sent by the memory controller, and sends the N to-be-read words to the processor.
  • the memory is based on the addresses of the N words to be read. Obtaining the N words to be read from the memory lines of the N to-be-read words stored in the memory, and sending the N words to be read to the cache device, so the cache device can receive the N to be sent by the memory controller. Read the word and send the N words to be read to the processor. .
  • the cache device receives a word other than the N to-be-read words in the memory line to which the N to-be-read words are sent by the memory controller.
  • the cache device after receiving the N words to be read, the cache device receives the words other than the N words to be read in the memory line to which the N words to be read are sent by the memory controller. Since the cache device does not receive the words other than the N words to be read in the memory line to which the N words to be read are sent by the memory controller when receiving the N words to be read, the cache device acquires the N items to be read. When the word is read, it is not interfered by the reading of other words, so that the delay of reading the N words to be read is not increased, and the reading delay of the word to be read can be reduced compared with the prior art.
  • the memory access method provided by the embodiment of the present invention receives at least two read commands sent by the processor by the cache device, and forwards the at least two to the memory controller when the N to-be-read words are not cached in the cache device. Reading the command, receiving the N to-be-sent words sent by the memory controller, and sending the N to-be-read words to the processor, and then receiving the N to-be-sents sent by the memory controller A word other than the N words to be read in the memory line to which the word belongs.
  • the cache device Since the cache device does not need to acquire other words in the memory row to which the N words to be read belong in the process of acquiring the N words to be read, the delay of reading the N words to be read is not increased, and the existing Compared with the technology, the read delay of the word to be read can be reduced.
  • Embodiment 2 is a flowchart of Embodiment 2 of a memory access method according to the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • the memory controller receives N read commands sent by the cache device, where N is an integer greater than or equal to 2.
  • Each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read address.
  • the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read.
  • the memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the address of the N to-be-read words, and sends the N to the cache device. The word to be read.
  • the memory controller determines, according to the address of the N words to be read, the memory line to which the N words to be read belong, and then obtains the N from the memory line to which the N words to be read are stored in the memory.
  • the words to be read are sent to the cache device.
  • the memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong, and sends the other words to the cache device.
  • the memory controller obtains other words other than the N words to be read from the memory lines of the N to-be-read words stored in the memory, and sends the acquired other words to the cache device.
  • the words other than the N words to be read in the memory line to which the N words to be read are not temporarily processed are not processed, but are preferentially
  • the N words to be read are sent to the cache device, so the cache device does not interfere with the reading of other words when acquiring the N words to be read, thereby not increasing the delay of the cache device reading the N words to be read.
  • the read delay of the word to be read can be reduced.
  • the memory access method receives the N read commands sent by the cache device through the memory controller, and obtains the N from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words. Reading the words, and preferentially transmitting the N words to be read to the cache device, and then acquiring words other than the N words to be read from the memory lines to which the N words to be read belong, and The other words are sent to the cache device. Since the memory controller does not need to acquire other words in the memory row of the N words to be read in the process of acquiring the N words to be read, and the cache device does not receive other words when acquiring the N words to be read. The interference is read so that the delay of reading the N words to be read is not increased, and the read delay of the word to be read can be reduced as compared with the prior art.
  • Embodiment 3 is a flowchart of Embodiment 3 of a memory access method according to the present invention. As shown in FIG. 3, the method in this embodiment may include:
  • the processor sends N read commands to the cache device.
  • Each read command includes an address of the word to be read, and each read command may further include an identifier of the register. Specifically, the read command is used to indicate that the word to be read is stored in the register of the processor.
  • the N is 2, and the cache device receives two read commands sent by the processor.
  • the two read commands are, for example, LoadR0, Addr1+8, LoadR1, and addr1+16. These two read commands are used to read different words in the same memory line. LoadR0 and Addr1+8 are used to indicate that the address of the memory line with the address Addr1 is 8 is stored in register R0, LoadR1, addr1 +16 is used to indicate that the word with address 16 in the memory line at address Addr1 is stored in register R1.
  • the cache device determines that the N to-be-read words are not cached.
  • the cache device forwards the N read commands to the memory controller.
  • the cache device receives the read command to determine whether the word to be read is cached, and the cache device can determine, according to the address of the word to be read, whether the words to be read have been cached, if the cache device has Cache the words to be read, and the cache device stores the words to be read in the corresponding registers. If the two words to be read are not cached in the cache device, that is, the cache miss, the cache device forwards to the memory controller.
  • the two read commands this embodiment is an example in which the cache device does not cache all the words to be read. If one of the words to be read has been cached in the cache device, the cache device stores the word to be read in the corresponding register, and the cache device sends another read command to the memory controller.
  • the memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words.
  • the memory controller preferentially obtains the to-be-read word with address 8 and the address to be read 16 from the memory row with the address Addr1 according to the addresses of the two words to be read: Addr1+8 and Addr1+16. word.
  • Each of the words to be read in the embodiment is stored in one of the memory pixels of the memory line to which the word to be read belongs.
  • each memory row in the memory controller stores 8 words, which are stored in different memory particles, for example: word 0 in the memory row (representing the 0th in the memory row) The word is stored in the memory particle 0, the word 1 in the memory line (representing the first word in the memory line) is stored in the memory particle 1, and so on, and will not be described here.
  • the memory controller can determine the memory line to which the word to be read belongs according to the address Addr1, and then obtain the word 1 from the memory particle 1 corresponding to the address 8 according to the address 8 and the address 16, the word 1 is to be The word is read, and word 2 is obtained from the memory particle 2 corresponding to address 16, which is the word to be read.
  • the memory controller sends the priority of the N to-be-read words and the N to-be-read words to the cache device.
  • the memory controller after the memory controller acquires the two words to be read, the word 1 and the word 2, the memory controller takes the priority of the word 1 and the word 1 and the priority of the word 2. Accordingly, the cache device also receives the priority of word 1 and word 1 transmitted by the memory controller, and the priority of word 2 and word 2.
  • the memory controller determines the priority of all words according to the read/write frequency of all words in the memory line, that is, if the read/write frequency of the word 0 is higher than the read/write frequency of the word 1, the priority of the word 0 is higher than The priority of word 1, as shown in Figure 4, the order of priority in the memory line from high to low is: word 0 to word 7.
  • the cache device sends the N to-be-read words to the processor.
  • the cache device may store each of the to-be-read words in the corresponding register of the processor according to the identifier of the register.
  • the address of the word 1 carried by the cache device according to word 1 (Addr1+8), it can be determined that the corresponding read command is: LoadR0, Addr1+8, and then the cache device stores the received word 1 in the register R0 according to R0.
  • the cache device can determine that the corresponding read command is: LoadR1, Addr1+16 according to the address of the word 2 carried by the word 2 (Addr1+16), and then the cache device stores the received word 2 in the register R1 according to R1.
  • the cache device caches the N to-be-read words according to a priority of the N to-be-read words from high to low.
  • the cache device may also cache the two words to be read: word 1 and word 2.
  • the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache device is based on the word.
  • Addr1 in the address of 1 determines the cache line corresponding to the memory line of the address Addr1, and then stores the word 1 at the position where the cache line address is 8 according to the address 8 in the address of the word 1.
  • the cache device determines the cache line corresponding to the memory line of the address Addr1 according to Addr1 in the address of the word 2, and then stores the word 2 at the position where the cache line address is 16 according to the address 16 in the address of the word 2.
  • the cache device may further cache the word 1 and then cache the word 2 according to the priority of the word 1 being higher than the priority of the word 2 (as shown in FIG. 4).
  • the memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong.
  • the memory controller sends a priority of the other words and the other words to the cache device.
  • the memory controller After the memory controller sends the word 1 and the word 2 to the cache device, the memory controller acquires words other than the word 1 and the word 2 in the memory line to which the word 1 and the word 2 belong, such as a memory controller. Then obtain word 0, word 3, word 4, word 5, word 6, word 7, these words can be called prefetch words, and then send the priority of word 0 and word 0, the priority of word 3 and word 3 to the cache device.
  • the priority of the level, word 4 and word 4 the priority of word 5 and word 5, the priority of word 6 and word 6, the priority of word 7 and word 7.
  • the cache device can receive the priority of word 0 and word 0 sent by the memory controller, the priority of word 3 and word 3, the priority of word 4 and word 4, the priority of word 5 and word 5, word 6 And the priority of word 6, the priority of word 7 and word 7.
  • the cache device caches the other words according to a priority of the other words from high to low.
  • the cache device may further cache words other than the two words to be read: word 0, word 3, word 4, word 5, word 6, and word 7. Specifically, the cache device may be based on the word.
  • the address of 0 determines the Addr1 in the address of the word 0, determines the cache line corresponding to the memory line of the address Addr1, and then stores the word 0 at the position where the cache line address is 0 according to the address 0 in the address of the word 0. .
  • the caching process of word 3, word 4, word 5, word 6, and word 7 is similar, and will not be described here.
  • the cache device may also cache the respective words according to the order of priority from high to low: word 0>word 3>word 4>word 5>word 6>word 7, and the cache order is: word 0, word 3 , word 4, word 5, word 6, word 7.
  • the memory controller does not need to acquire and send other words in the memory row of the N to-be-read words in the process of acquiring and transmitting the N words to be read, and the cache device is acquiring the N to During the process of reading a word, it is not necessary to obtain other words in the memory row of the N words to be read, so that the delay of reading the N words to be read is not increased, and the word to be read can be reduced compared with the prior art. Read latency.
  • FIG. 6 is a flowchart of Embodiment 4 of a memory access method according to the present invention. As shown in FIG. 6, the method in this embodiment is based on any one of Embodiments 1 to 3 or 5 of the method of the present invention, and further, the embodiment is The method can also include:
  • the processor sends M write commands to the cache device.
  • M is an integer greater than or equal to 1
  • each of the write commands includes an address to be written and the address to be written
  • the address to be written includes an address of the memory row to be written and the writing to be written The address in the belonging memory row, the write command is used to write the to-be-written.
  • the M is 1 as an example.
  • the cache device receives a write command sent by the processor.
  • the write command is, for example, StoreR0, Addr1+16, and Addr1+16 indicates the address to be written. That is, the address in the memory row of the address Addr1 is 8 address, R0 means to store the register to be written, and StoreR0 and Addr1+16 are used to indicate that the word in the register R0 is stored to the address of the address Addr1+16.
  • the cache device writes each of the to-be-written words into a corresponding position in a corresponding cache line of each memory line to be written according to the address to be written.
  • the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache device determines the cache line corresponding to the memory line with the address Addr1 according to Addr1 in the address to be written, and then according to the Address 16, in the address of the letter, stores the word to be written in the cache
  • the row address is 16 locations.
  • the cache device forwards M write commands to the memory controller.
  • the cache device may determine, according to the write command, whether the memory line with the address of Addr1 is cached. If it is cached, execute S406. If not, the cache device memory controller forwards the write command. This embodiment is described as an example of a memory behavior of a cache device that is not cached to be written.
  • the memory controller sends, according to the write command, a word other than the word corresponding to the M addresses to be written in the M memory lines to be written to the cache device.
  • the memory controller receives a write command that is sent by the cache device, including the address to be written, and the memory controller may stop acquiring the word corresponding to the address to be written according to the write command, and obtain the memory to be written.
  • the word other than word 2 (the word corresponding to the address 16) in the memory line with the address Addr1 is obtained, and these words are Word 0, word 1, word 3, word 4, word 5, word 6, word 7, these words can also be called prefetch words, and then send the address of word 0 and word 0 (Addr1+0), word to the cache device Address of 1 and word 1 (Addr1+8), address of word 3 and word 3 (Addr1+24), address of word 4 and word 4 (Addr1+32), address of word 5 and word 5 (Addr1+40) , the address of Word 6 and Word 6 (Addr1+48), the address of Word 7 and Word 7 (Addr1+56).
  • the memory controller can prioritize word 0 and word 0, priority of word 1 and word 1, priority of word 3 and word 3, priority of word 4 and word 4, word 5 and word 5
  • the priority, the priority of word 6 and word 6, the priority of word 7 and word 7 are sent to the cache device.
  • the cache device caches words other than words corresponding to the M addresses to be written in the M memory lines to be written.
  • the cache device may cache the word 0, word 1, word 3, word 4, word 5, word 6, and word 7 sent by the received memory controller. Specifically, the cache device may determine Addr1 in the address of the word 0 according to the address of the word 0, determine a cache line corresponding to the memory line of the address Addr1, and then store the word 0 according to the address 0 in the address of the word 0. The location where the cache line address is 0. The caching process of word 1, word 3, word 4, word 5, word 6, and word 7 is similar, and will not be described here.
  • the cache device may also cache the individual words according to the order of priority from high to low: word 0>word 1>word 3>word 4>word 5>word 6>word 7.
  • the cache order is: word 0, Word 1, word 3, word 4, word 5. Word 6, word 7.
  • the cache device sends, to the memory controller, a cache line corresponding to the M memory lines to be written.
  • the cache device after the cache device caches all the words in the memory row, the cache device sends a cache line corresponding to the memory row to be written to the memory controller, that is, the cache device uses the word 0, the word 1, the word to be written, and the word. 3. Word 4, Word 5, Word 6, and Word 7 are sent to the memory controller.
  • the memory controller rewrites the M memory lines to be written into the cache lines corresponding to the M memory lines to be written.
  • the memory controller receives the cache line corresponding to the memory line to be written by the cache device, and the memory controller rewrites the memory line with the address Addr1 to the cache line sent by the received cache device, that is, the memory with the address Addr1. All words in the line are rewritten as word 0, word 1, to be written, word 3, word 4, word 5, word 6, word 7, thereby realizing the word rewriting process.
  • the overhead can be saved.
  • FIG. 8 is a flowchart of Embodiment 5 of the memory access method of the present invention. As shown in FIG. 8, the method in this embodiment may include:
  • the processor sends N read commands to the cache device.
  • each read command includes an address of the word to be read and an identifier of the register, the read command is used to indicate that the word to be read is stored in the register.
  • the N is 3, and the cache device receives three read commands sent by the processor.
  • the three read commands are, for example, LoadR0, Addr0+16, LoadR1, and addr1+32.
  • LoadR1, addr2+48, these three read commands are used to read the words in different memory lines
  • LoadR0, Addr0+16 is used to indicate that the address of the memory line with the address Addr0 is 16 is stored in register R0.
  • LoadR1, addr1+32 are used to indicate that the address of the memory line with the address Addr1 is 32 is stored in the register R1, and LoadR2, addr2+48 is used to indicate that the address in the memory line with the address Addr2 is 48.
  • the word is stored in register R2.
  • the cache device determines that the N to-be-read words are not cached.
  • the cache device forwards the N read commands to a memory controller.
  • the cache device receives the read command to determine whether the word to be read has been cached, and the cache device can determine, according to the address of the word to be read, whether the word to be read is cached, if the cache If the word to be read is cached in the device, the cache device stores the word to be read in the corresponding register. If the three words to be read are not cached in the cache device, that is, the cache miss, the cache device is directed to the memory controller. The three read commands are forwarded; this embodiment is an example in which the cache device does not cache all the words to be read.
  • the memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words.
  • the memory controller preferentially obtains the to-be-read word and the slave address with the address of 16 from the memory row with the address Addr0 according to the addresses of the three words to be read: Addr0+16, Addr1+32, and Addr2+48.
  • the word to be read with the address of 32 is preferentially obtained
  • the word to be read with the address of 48 is preferentially obtained from the memory line with the address of Addr2.
  • the memory controller stops acquiring the word of the address 56 from the memory line of the address Addr3 according to the address to be written: Addr3+56, wherein each word in the embodiment is stored in the memory line of the word.
  • Addr3+56 wherein each word in the embodiment is stored in the memory line of the word.
  • each memory row in the memory controller stores 8 words, which are stored in different memory particles, for example, word 00 in memory row 0 (representing memory row 0)
  • word 00 in memory row 0 (representing memory row 0)
  • the 0th word is stored in the memory granule
  • the word 11 in the memory line 1 (representing the first word in the memory line 1) is stored in the memory granule 1, and so on, and will not be described again here.
  • the word 00, the word 10, and the word 20 are stored in the memory granule 0, and the word 01, the word 11, and the word 21 are stored in the memory granule 1, and so on, and are not described herein again.
  • the memory controller can determine the memory line 0 to which the word to be read belongs according to the address Addr0, and then obtain the word 02 from the memory particle 2 corresponding to the address 16 according to the address 16, the word 02 is to be read.
  • the memory controller can determine the memory line 1 to which the word to be read belongs according to the address Addr1, and then obtain the word 14 from the memory particle 4 corresponding to the address 32 according to the address 32, the word 14 is the word to be read; the memory controller can be based on The address Addr2 determines the memory line 2 to which the word to be read belongs, and then obtains the word 26 from the memory grain 6 corresponding to the address 48 according to the address 48, which is the word to be read.
  • the memory controller sends the priority of the N to-be-read words and the N to-be-read words to the cache device.
  • the memory controller After the memory controller acquires the three words to be read, namely word 02, word 14 and word 26, the memory controller sets the priority of word 01, word 01, the priority of word 14 and word 14, and the word.
  • the priority of 26 and the word 26 is sent to the cache device, so that the cache device can distinguish which of the received three words is the word to be read according to the address of the word 01, the address of the word 14, and the address of the word 26.
  • each of the above words carries the address of each word.
  • the cache device sends the N to-be-read words to the processor.
  • the cache device stores each of the words to be read in the corresponding register according to the identifier of the register. For example, the cache device can determine that the corresponding read command is: LoadR0, Addr0+16 according to the address of the word 02 (Addr0+16), and then the cache device stores the received word 02 in the register R0 according to R0. Based on the address of the word 14 (Addr1+32), the cache device can determine that the corresponding read command is: LoadR1, Addr1+32, and then the cache device stores the received word 14 in the register R1 according to R1. Based on the address of word 26 (Addr1+32), the cache device can determine that the corresponding read command is: LoadR2, Addr2+48, and then the cache device stores the received word 26 in register R2 according to R2.
  • the cache device caches the N to-be-read words according to an order of priority of the N to-be-read words.
  • the cache device may also cache the three words to be read: word 02, word 14, and word 26.
  • the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache The device determines the cache line 0 corresponding to the memory line 0 of the address Addr0 according to Addr0 in the address of the word 02, and then stores the word 02 in the position of the cache line 0 address 16 according to the address 16 in the address of the word 02. .
  • the cache device determines the cache line 1 corresponding to the memory line 1 of the address Addr1 according to Addr1 in the address of the word 14, and then stores the word 14 in the cache line 1 address 32 according to the address 32 in the address of the word 14. position.
  • the cache device determines the cache line 2 corresponding to the memory line 2 of the address Addr2 according to Addr2 in the address of the word 26, and then stores the word 26 in the cache line 2 address 48 according to the address 48 in the address of the word 26. position.
  • the cache device may also have a priority higher than the priority of the word 14 according to the priority of the word 14, the priority of the word 14 is higher than the priority of the word 02, the word 26 is cached first, then the word 14 is cached, and then the word 02 is cached. .
  • the memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong.
  • the memory controller according to the order of priority of each word except the N to-be-read words belonging to the same memory particle in the memory line to which the N to-be-read words belong, to the The cache device transmits the priority of the other words and the other words.
  • the memory controller acquires the word 02, the word 14 and the word 26, the memory controller acquires the word in the memory line 0 of the word 02, except the word 02, and the memory line 1 of the word 14 belongs to Words other than the word 14, words 26 of the memory line 2 other than the word 26, which may be referred to as prefetched words, are then sent to the cache device for the words and the addresses of the words. Accordingly, the cache device can receive the words sent by the memory controller and the addresses of the words.
  • the memory controller may send, to the cache device, the N to-be-read words in the memory row to which the N words to be read belong according to the priority of the respective words belonging to the same memory particle from high to low. Other words than words.
  • the memory controller sequentially sends word 20, word 10, and word 00 to the cache device.
  • the memory controller sequentially sends the word 21, the word 11, and the word 01 to the cache device.
  • the memory controller sequentially sends the word 22, word 12 to the cache device.
  • the memory controller sequentially sends the word 23, word 13, and word 03 to the cache device.
  • the memory controller sequentially sends the word 24, word 04 to the cache device.
  • the memory controller sequentially sends the word 25, word 15, and word 05 to the cache device.
  • the memory controller sequentially sends the word 16, word 06 to the cache device.
  • the memory controller sequentially sends word 27, word 17, word 07 to the cache device.
  • the memory controller If the memory controller can simultaneously send 8 words to the cache device, the memory controller first sends word 27, word 26, word 25, word 14, word 23, word 02, word 21, word 20 to the cache device, and then sends the word. 17. Word 16, Word 15, Word 24, Word 13, Word 22, Word 11, Word 10, and then send word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
  • the memory controller If the memory controller can send less than 8 words to the cache device at the same time, the memory controller first sends the word 26, the word 14, the word 02, the word 27, the word 25, to the cache device according to the order of priority from high to low. Word 23, word 21, word 20; then send word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10 according to the order of priority from high to low, and then according to the priority In the high to low order, word 07, word 06, word 05, word 04, word 03, word 12, word 01, and word 00 are transmitted.
  • the memory controller can first send the word 26, the word 14, the word 02, and then send the word to the cache device according to the order of priority from high to low: word 27 , word 25, word 23, word 21, word 20, word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10, word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
  • the memory controller may also send the priority of each of the above words to the cache device.
  • the cache device caches the order according to the priority of the other words from high to low. Said other words.
  • the cache device caches the other words to corresponding locations in the cache line corresponding to the memory lines to which the other words belong according to the addresses of the other words. For example, word 07 is stored at the location where the cache line 0 address is 56, based on address 40 in the address of word 07.
  • the caching process for other words is similar and will not be described here.
  • the cache device may also cache the above words according to the priority of each word described in S509 from high to low. For example, the cache device first caches the word 27, the word 25, and the word according to the order of priority from high to low. 23, word 21, word 20; according to the order of priority from high to low, cache word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10; then according to the priority from high In the low order, cache word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
  • the memory controller does not need to acquire and send other words in the memory row of the N to-be-read words in the process of acquiring and transmitting the N words to be read, and the cache device is acquiring the N to During the process of reading a word, it is not necessary to obtain other words in the memory row of the N words to be read, so that the delay of reading the N words to be read is not increased, and the word to be read can be reduced compared with the prior art. Read latency. At the same time, since the memory controller receives the second write command, it does not need to send all the words in the entire memory row to the cache device, thereby saving the overhead.
  • the cache device of this embodiment includes: a receiving unit 11, a processing unit 12, and a sending unit 13; wherein, the receiving unit 11 is configured to receive processing.
  • N read commands sent by the device the N is an integer greater than or equal to 2
  • each read command includes an address of a word to be read
  • the address of the word to be read includes an address of a memory line to which the word to be read belongs
  • the read command is used to read the word to be read
  • the processing unit 12 is configured to determine whether the N words to be read are cached in the cache device
  • the sending unit 13 is configured to: when the processing unit 12 determines that the N words to be read are not cached in the cache device, forward the N read commands to the memory controller;
  • the receiving unit 11 is further configured to receive the The N words to be read sent by the memory controller, and the sending unit 13 are further configured to send the N to be read words to the processor;
  • the receiving unit 11 is further configured to receive the sending by the memory controller The N waiting to be read in the memory line to which the word to be read belongs Read words other than words.
  • the receiving unit 11 is configured to receive the first word sent by the memory controller, where the receiving unit 11 is configured to receive the first word and the first word sent by the memory controller.
  • the processing unit 12 is further configured to cache the location according to the priority of the first word from high to low. a first word; wherein the first word is a word other than the N to-be-read words in the memory line to which the N to-be-read words or the N to-be-read words belong.
  • the cache device of this embodiment may be used to perform the technical solution executed by the cache device in the foregoing method embodiment of the present invention.
  • the implementation principle and technical effects are similar, and details are not described herein again.
  • FIG. 11 is a schematic structural diagram of Embodiment 1 of a memory controller according to the present invention.
  • the memory controller of this embodiment includes: a receiving unit 21, a processing unit 22, and a sending unit 23; wherein, the receiving unit 21 is configured to Receiving N read commands sent by the cache device, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and an address of the word to be read includes an memory line to which the word to be read belongs And an address of the word to be read in the memory line, the read command is used to read the word to be read, and the processing unit 22 is configured to: according to the address of the N words to be read, Obtaining the N to-be-read words in the memory row to which the N words to be read belong; the sending unit 23 is configured to send the N to-be-read words to the cache device; the processing unit 22 is further configured to use the N The words in the memory line to which the word to be read belong are obtained other than the N words to be read; the
  • the sending unit 23 is configured to send the other words to the cache device, where: the sending unit 23 is configured to: according to the N memory cells belonging to the same memory particle in the memory row to which the N to be read words belong The other words are transmitted to the cache device in a descending order of priority of the words other than the read word.
  • the sending unit 23 is configured to send the first word to the cache device, where the sending unit 23 is configured to send, to the cache device, a priority of the first word and the first word, where The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
  • the processing unit 22 is further configured to: before the transmitting unit 23 sends the first word to the cache device, determine, according to the read/write frequency of each word in the memory line to which the N to-be-read words belong, The priority of the word.
  • each word in the memory row to which the N words to be read belong is stored in one memory particle.
  • the memory controller of this embodiment may be used to perform the technical solution executed by the memory controller in the foregoing method embodiment of the present invention, and the implementation principle and technical effects thereof are similar, and details are not described herein again.
  • FIG. 12 is a schematic structural diagram of Embodiment 1 of a computer device according to the present invention.
  • the computer device provided in this embodiment may include computing capability.
  • the computer device 700 may include: a cache device 710, a memory controller 720, a processor 730, and a memory device 740; the computer device 700 may further include: a communication bus 750, wherein the cache device 710, the memory controller 720, and the processing The memory device 730 and the memory device 740 can complete communication between the devices through the communication bus 750.
  • the computer device 700 can also include a communication interface 760 through which the processor 730 can communicate with external devices.
  • the cache device 710 can adopt the structure shown in FIG. 10, and correspondingly, the technical solution executed by the cache device in the foregoing method embodiment of the present invention can be executed, and details are not described herein; the memory controller 720 can be configured as shown in the figure.
  • the configuration shown in FIG. 11 can perform the execution scheme executed by the memory controller in the foregoing method embodiment of the present invention, and details are not described herein again.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing storage medium includes: read-only memory (English: Read-Only Memory, ROM for short), random access memory (English: Random Access Memory, RAM), disk or A variety of media such as optical discs that can store program code.

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)

Abstract

Embodiments of the present invention provide a memory access method and apparatus, and a computer device. The method comprises: a buffer device receives N read commands from a processor, wherein N is an integer greater than or equal to 2, each read command comprises addresses of to-be-read characters, the addresses of the to-be-read characters comprise an address of a memory row to which the to-be-read characters belong and addresses of the to-be-read characters in the memory row, and the read command is used for reading the to-be-read characters; when N to-be-read characters are not temporarily stored in the buffer device, the buffer device forwards the N read commands to a memory controller; the buffer device receives the N to-be-read characters sent by the memory controller, and sends the N to-be-read characters to the processor; and the buffer device receives other characters except the N to-be-read characters in the memory row to which the N to-be-read characters sent by the memory controller belong. In a process in which the buffer device acquires the N to-be-read characters, the buffer device does not need to acquire other characters in the memory row in which the N to-be-read characters are located, the time delay of reading the N to-be-read characters is not increased, and accordingly, the time delay of reading the characters to be read is decreased.

Description

内存访问方法、装置和计算机设备Memory access method, device and computer device 技术领域Technical field
本发明实施例涉及计算机技术领域,尤其涉及一种内存访问方法、装置和计算机设备。The embodiments of the present invention relate to the field of computer technologies, and in particular, to a memory access method, apparatus, and computer device.
背景技术Background technique
处理器所需要使用的数据一般存储在内存中,处理器需要从内存中获取数据并存储在缓存中以进行使用,其中,处理器获取使用的数据是以字(英文:word)为单位进行获取,现有技术中,当处理器需要获取某一数据时,发送针对该数据的读指令给缓存,该读指令用于获取处理器所需要的字,即关键字;如果查找到这一数据,则将该数据返回给处理器;如果在缓存中未找到该数据,则会由缓存将读指令转发给内存,内存根据该读指令将这一关键字所属的内存行都返回给缓存,以在缓存中形成缓存行(英文:cacheline)。其中,一个内存行可以包括8个字,例如包括第0、1、2、3、4、5、6、7这8个字,当读指令用于读取第6个字时,内存将整个内存行按照第6、7、1、2、3、4、5个字的顺序返回给缓存,即在内存行内部会优先返回读指令所需的关键字,缓存行中除了关键字以外的字称为预取字;然后缓存再将关键字返回给处理器。The data that the processor needs to use is generally stored in the memory. The processor needs to obtain data from the memory and store it in the cache for use. The data acquired by the processor is obtained in units of words (English: word). In the prior art, when the processor needs to acquire a certain data, a read instruction for the data is sent to the cache, and the read instruction is used to acquire a word required by the processor, that is, a keyword; if the data is found, The data is returned to the processor; if the data is not found in the cache, the read instruction is forwarded to the memory by the cache, and the memory returns the memory line to which the keyword belongs to the cache according to the read instruction, so as to A cache line is formed in the cache (English: cacheline). Wherein, a memory line can include 8 words, for example, 8 words including 0, 1, 2, 3, 4, 5, 6, and 7. When the read command is used to read the 6th word, the memory will be the whole. The memory lines are returned to the cache in the order of the sixth, seventh, first, second, third, fourth, and fifth words, that is, the keywords required for the read instruction are preferentially returned inside the memory line, and the words other than the keywords in the cache line are deleted. It is called a prefetch word; then the cache returns the keyword to the processor.
但是,若处理器通过缓存向内存同时发送多个读指令时,内存需要将一个读指令对应的一个内存行中的所有字全部返回给缓存之后,内存才能根据另一读指令向缓存返回另一内存行中的字,此时缓存才能向处理器返回该另一读指令所指示的关键字,从而增加了其它关键字的读取延迟。However, if the processor simultaneously sends multiple read instructions to the memory through the cache, the memory needs to return all the words in one memory line corresponding to one read instruction to the cache, and the memory can return another cache to the cache according to another read instruction. The word in the memory line, at which point the cache can return the keyword indicated by the other read instruction to the processor, thereby increasing the read latency of other keywords.
发明内容Summary of the invention
本发明实施例提供一种内存访问方法、装置和计算机设备,用于降低处理器所需字的读取延迟。Embodiments of the present invention provide a memory access method, apparatus, and computer apparatus for reducing a read delay of a word required by a processor.
第一方面,本发明实施例提供一种内存访问方法,包括:In a first aspect, an embodiment of the present invention provides a memory access method, including:
缓存设备接收处理器发送的N个读命令,所述N为大于或等于2的整数, 所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;The cache device receives N read commands sent by the processor, where N is an integer greater than or equal to 2, Each of the read commands includes an address of a word to be read, the address of the word to be read includes an address of a memory line to which the word to be read belongs, and an address of the word to be read in the memory line, the read command For reading the word to be read;
当所述缓存设备中未缓存所述N个待读字时,所述缓存设备向内存控制器转发所述N个读命令;When the N words to be read are not cached in the cache device, the cache device forwards the N read commands to the memory controller;
所述缓存设备接收所述内存控制器发送的所述N个待读字,以及向所述处理器发送所述N个待读字;The cache device receives the N to-be-sent words sent by the memory controller, and sends the N to-be-read words to the processor;
所述缓存设备接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。The cache device receives other words in the memory row to which the N words to be read are sent by the memory controller, except the N to-be-read words.
在第一方面的第一种可能的实现方式中,所述缓存设备接收所述内存控制器发送的第一字,包括:In a first possible implementation manner of the first aspect, the receiving, by the cache device, the first word sent by the memory controller includes:
所述缓存设备接收所述内存控制器发送的所述第一字和所述第一字的优先级;Receiving, by the cache device, a priority of the first word and the first word sent by the memory controller;
所述方法,还包括:The method further includes:
所述缓存设备根据所述第一字的优先级从高到低的顺序,缓存所述第一字;The cache device caches the first word according to a priority of the first word from high to low;
其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
第二方面,本发明实施例提供一种内存访问方法,包括:In a second aspect, an embodiment of the present invention provides a memory access method, including:
内存控制器接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;The memory controller receives N read commands sent by the cache device, the N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the word to be read An address of the associated memory line and an address of the word to be read in the memory line, the read command is used to read the word to be read;
所述内存控制器根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字,并向所述缓存设备发送所述N个待读字;The memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the address of the N words to be read, and sends the N to be read to the cache device. word;
所述内存控制器从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字,并向所述缓存设备发送所述其它字。The memory controller acquires words other than the N to-be-read words from the memory lines to which the N words to be read belong, and sends the other words to the cache device.
在第二方面的第一种可能的实现方式中,所述内存控制器向所述缓存设备发送所述其它字,包括:In a first possible implementation manner of the second aspect, the memory controller sends the other words to the cache device, including:
所述内存控制器根据所述N个待读字所属内存行中属于同一内存颗粒的 除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字。The memory controller belongs to the same memory particle according to the memory line to which the N words to be read belong The other words are transmitted to the cache device in descending order of priority of the words other than the N words to be read.
结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述内存控制器向所述缓存设备发送第一字,包括:With reference to the second aspect, or the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the memory controller sends the first word to the cache device, including:
所述内存控制器向所述缓存设备发送所述第一字和所述第一字的优先级;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The memory controller sends a priority of the first word and the first word to the cache device, where the first word is the N words to be read or the N words to be read belong to A word other than the N words to be read in the memory line.
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述内存控制器向所述缓存设备发送所述第一字之前,还包括:With the second possible implementation of the second aspect, in a third possible implementation manner of the second aspect, before the sending, by the memory controller, the first word to the cache device, the method further includes:
所述内存控制器根据所述N个待读字所属内存行中各个字的读写频率,确定所述各个字的优先级。The memory controller determines the priority of each word according to the read/write frequency of each word in the memory line to which the N words to be read belong.
结合第二方面或第二方面的第一种至第三种可能的实现方式中的任意一种,在第二方面的第四种可能的实现方式中,所述N个待读字所属内存行中的每个字存储在一个内存颗粒中。With reference to the second aspect, or any one of the first to the third possible implementation manners of the second aspect, in the fourth possible implementation manner of the second aspect, the memory lines of the N to-be-read words belong to Each word in it is stored in a memory particle.
第三方面,本发明实施例提供一种缓存设备,包括:In a third aspect, an embodiment of the present invention provides a cache device, including:
接收单元,用于接收处理器发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;a receiving unit, configured to receive N read commands sent by the processor, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
处理单元,用于确定所述缓存设备中是否缓存所述N个待读字;a processing unit, configured to determine whether the N to-be-read words are cached in the cache device;
发送单元,用于当所述处理单元确定所述缓存设备中未缓存所述N个待读字时,向内存控制器转发所述N个读命令;a sending unit, configured to: when the processing unit determines that the N to-be-read words are not cached in the cache device, forward the N read commands to a memory controller;
所述接收单元,还用于接收所述内存控制器发送的所述N个待读字,以及The receiving unit is further configured to receive the N to-be-sent words sent by the memory controller, and
所述发送单元,还用于向所述处理器发送所述N个待读字;The sending unit is further configured to send the N to-be-read words to the processor;
所述接收单元,还用于接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。The receiving unit is further configured to receive, in the memory row to which the N to-be-read words are sent by the memory controller, other words than the N to-be-read words.
在第三方面的第一种可能的实现方式中,所述接收单元用于接收所述内存控制器发送的第一字,包括:所述接收单元用于,接收所述内存控制器发送的所述第一字和所述第一字的优先级; In a first possible implementation manner of the third aspect, the receiving unit is configured to receive the first word sent by the memory controller, where: the receiving unit is configured to receive, by the memory controller, Describe the priority of the first word and the first word;
所述处理单元,还用于根据所述第一字的优先级从高到低的顺序,缓存所述第一字;The processing unit is further configured to cache the first word according to a priority of the first word from high to low;
其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
第四方面,本发明实施例提供一种内存控制器,包括:In a fourth aspect, an embodiment of the present invention provides a memory controller, including:
接收单元,用于接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;a receiving unit, configured to receive N read commands sent by the cache device, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
处理单元,用于根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字;a processing unit, configured to acquire the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words;
发送单元,用于向所述缓存设备发送所述N个待读字;a sending unit, configured to send the N to-be-read words to the cache device;
所述处理单元,还用于从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字;The processing unit is further configured to obtain, from the memory lines to which the N to-be-read words belong, words other than the N to-be-read words;
所述发送单元,还用于向所述缓存设备发送所述其它字。The sending unit is further configured to send the other words to the cache device.
在第四方面的第一种可能的实现方式中,所述发送单元用于向所述缓存设备发送所述其它字,包括:所述发送单元用于根据所述N个待读字所属内存行中属于同一内存颗粒的除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字。In a first possible implementation manner of the fourth aspect, the sending unit is configured to send the other words to the cache device, where: the sending unit is configured to: according to the memory line to which the N to-be-read words belong The other words belonging to the same memory particle in a descending order of priority of each of the N words to be read are sent to the cache device.
结合第四方面或第四方面的第一种可能的实现方式,在第四方面的第二种可能的实现方式中,所述发送单元用于向所述缓存设备发送第一字,包括:所述发送单元用于,向所述缓存设备发送所述第一字和所述第一字的优先级;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。With reference to the fourth aspect, or the first possible implementation manner of the fourth aspect, in a second possible implementation manner of the fourth aspect, the sending unit is configured to send the first word to the cache device, including: The sending unit is configured to send a priority of the first word and the first word to the cache device, where the first word is the N words to be read or the N words to be read A word other than the N words to be read in the associated memory line.
结合第四方面的第二种可能的实现方式,在第四方面的第三种可能的实现方式中,所述处理单元,还用于在所述发送单元向所述缓存设备发送所述第一字之前,根据所述N个待读字所属内存行中各个字的读写频率,确定所述各个字的优先级。In conjunction with the second possible implementation of the fourth aspect, in a third possible implementation manner of the fourth aspect, the processing unit is further configured to send, by the sending unit, the first to the cache device Before the word, the priority of each word is determined according to the frequency of reading and writing of each word in the memory line to which the N words to be read belong.
结合第四方面或第四方面的第一种至第三种可能的实现方式中的任意一种,在第四方面的第四种可能的实现方式中,所述N个待读字所属内存行中 的每个字存储在一个内存颗粒中。With reference to the fourth aspect, or any one of the first to the third possible implementation manners of the fourth aspect, in the fourth possible implementation manner of the fourth aspect, the memory lines of the N to-be-read words belong to Medium Each word is stored in a memory granule.
第五方面,本发明实施例提供一种计算机设备,包括:本发明实施例第三方面或第三方面的第一种可能的实现方式提供的缓存设备、本发明实施例第四方面或第四方面的各种可能的实现方式提供的内存控制器、处理器以及内存设备。In a fifth aspect, the embodiment of the present invention provides a computer device, including: a cache device provided by the third aspect of the embodiment or the first possible implementation manner of the third aspect, the fourth aspect or the fourth embodiment of the present invention Various possible implementations of aspects provide memory controllers, processors, and memory devices.
本发明实施例提供的内存访问方法、装置和计算机设备,通过缓存设备接收处理器发送的至少两个读命令,当所述缓存设备中未缓存所述N个待读字时,向内存控制器转发这至少两个读命令,再接收所述内存控制器发送的所述N个待读字,以及向所述处理器发送所述N个待读字,然后接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。由于缓存设备在获取这N个待读字的过程中不需要获取这N个待读字所属内存行中的其它字,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。The memory access method, device, and computer device provided by the embodiment of the present invention receive at least two read commands sent by the processor through the cache device, and when the N to-be-read words are not cached in the cache device, the memory controller is Forwarding the at least two read commands, receiving the N to-be-read words sent by the memory controller, and sending the N to-be-read words to the processor, and then receiving the location sent by the memory controller The words other than the N to-be-read words in the memory line to which the N words to be read belong are described. Since the cache device does not need to acquire other words in the memory row to which the N words to be read belong in the process of acquiring the N words to be read, the delay of reading the N words to be read is not increased, and the existing Compared with the technology, the read delay of the word to be read can be reduced.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明内存访问方法实施例一的流程图;1 is a flowchart of Embodiment 1 of a memory access method according to the present invention;
图2为本发明内存访问方法实施例二的流程图;2 is a flowchart of Embodiment 2 of a memory access method according to the present invention;
图3为本发明内存访问方法实施例三的流程图;3 is a flowchart of Embodiment 3 of a memory access method according to the present invention;
图4为本发明实施例提供的访问待读字的一种示意图;4 is a schematic diagram of accessing a word to be read according to an embodiment of the present invention;
图5为本发明实施例提供的内存行的一种示意图;FIG. 5 is a schematic diagram of a memory line according to an embodiment of the present invention;
图6为本发明内存访问方法实施例四的流程图;6 is a flowchart of Embodiment 4 of a memory access method according to the present invention;
图7为本发明实施例提供的访问待写字的一种示意图;FIG. 7 is a schematic diagram of access to be written according to an embodiment of the present invention;
图8为本发明内存访问方法实施例五的流程图;8 is a flowchart of Embodiment 5 of a memory access method according to the present invention;
图9为本发明实施例提供的访问待读字的一种示意图;FIG. 9 is a schematic diagram of accessing a word to be read according to an embodiment of the present invention;
图10为本发明缓存设备实施例一的结构示意图;10 is a schematic structural diagram of Embodiment 1 of a cache device according to the present invention;
图11这本发明内存控制器实施例一的结构示意图; 11 is a schematic structural diagram of Embodiment 1 of a memory controller according to the present invention;
图12为本发明计算机设备实施例一的结构示意图。FIG. 12 is a schematic structural diagram of Embodiment 1 of a computer device according to the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图1为本发明内存访问方法实施例一的流程图,如图1所示,本实施例的方法可以包括:1 is a flowchart of Embodiment 1 of a memory access method according to the present invention. As shown in FIG. 1, the method in this embodiment may include:
S101、缓存设备接收处理器发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字。S101. The cache device receives N read commands sent by the processor, where N is an integer greater than or equal to 2. Each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read The address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read.
本实施例中,缓存设备可以接收处理器的一个处理器核发送的N个读命令,或者,缓存设备可以接收处理器的多个处理器核发送的N个读命令,N个读命令中的每个读命令包括待读字的地址,其中,每个读命令包括的待读字的地址可以均不相同,待读字的地址包括该待读字所属内存行的地址以及该待读字在该所属内存行中的地址,每个读命令用于读用该读命令包括的地址所对应的待读字。In this embodiment, the cache device may receive N read commands sent by one processor core of the processor, or the cache device may receive N read commands sent by multiple processor cores of the processor, among the N read commands. Each of the read commands includes an address of the word to be read, wherein the address of the word to be read included in each read command may be different, and the address of the word to be read includes the address of the memory line to which the word to be read belongs and the word to be read is The address in the associated memory line, each read command is used to read the word to be read corresponding to the address included in the read command.
S102、当所述缓存设备中未缓存所述N个待读字时,所述缓存设备向内存控制器转发所述N个读命令。S102. When the N to-be-read words are not cached in the cache device, the cache device forwards the N read commands to the memory controller.
本实施例中,缓存设备可以根据N个待读取字的地址,判断是否已缓存该N个待读取字,若该缓存设备中已缓存该N个待读字,则缓存设备将该N个待读字发送给处理器,即将这N个字存储在处理器中的相应的寄存器中,若该缓存设备中未缓存所述N个待读字,即为cache miss,则缓存设备需要从内存中获取这N个待读字,缓存设备向内存控制器发送包括该N个读命令。In this embodiment, the cache device may determine, according to the addresses of the N words to be read, whether the N words to be read have been cached. If the N words to be read are cached in the cache device, the cache device substitutes the N. The words to be read are sent to the processor, that is, the N words are stored in corresponding registers in the processor. If the N words to be read are not cached in the cache device, that is, the cache miss, the cache device needs to be The N words to be read are obtained in the memory, and the cache device sends the N read commands to the memory controller.
S103、所述缓存设备接收所述内存控制器发送的所述N个待读字,以及向所述处理器发送所述N个待读字。S103. The cache device receives the N to-be-sent words sent by the memory controller, and sends the N to-be-read words to the processor.
本实施例中,内存在接收到上述N个读命令后,根据N个待读字的地址, 从内存中存储的该N个待读字所属内存行中获取这N个待读字,并将这N个待读字发送给缓存设备,因此,缓存设备可以接收内存控制器发送的N个待读字,并将这个N个待读字发送给处理器。。In this embodiment, after receiving the N read commands, the memory is based on the addresses of the N words to be read. Obtaining the N words to be read from the memory lines of the N to-be-read words stored in the memory, and sending the N words to be read to the cache device, so the cache device can receive the N to be sent by the memory controller. Read the word and send the N words to be read to the processor. .
S104、所述缓存设备接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。S104. The cache device receives a word other than the N to-be-read words in the memory line to which the N to-be-read words are sent by the memory controller.
本实施例中,缓存设备接收到N个待读字后,接收内存控制器发送的该N个待读字所属内存行中除这N个待读字之外的其它字。由于缓存设备在接收N个待读字时未接收内存控制器发送的该N个待读字所属内存行中除该N个待读字之外的其它字,因此缓存设备在获取这N个待读字时不会受到其它字的读取干扰,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。In this embodiment, after receiving the N words to be read, the cache device receives the words other than the N words to be read in the memory line to which the N words to be read are sent by the memory controller. Since the cache device does not receive the words other than the N words to be read in the memory line to which the N words to be read are sent by the memory controller when receiving the N words to be read, the cache device acquires the N items to be read. When the word is read, it is not interfered by the reading of other words, so that the delay of reading the N words to be read is not increased, and the reading delay of the word to be read can be reduced compared with the prior art.
本发明实施例提供的内存访问方法,通过缓存设备接收处理器发送的至少两个读命令,当所述缓存设备中未缓存所述N个待读字时,向内存控制器转发这至少两个读命令,再接收所述内存控制器发送的所述N个待读字,以及向所述处理器发送所述N个待读字,然后接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。由于缓存设备在获取这N个待读字的过程中不需要获取这N个待读字所属内存行中的其它字,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。The memory access method provided by the embodiment of the present invention receives at least two read commands sent by the processor by the cache device, and forwards the at least two to the memory controller when the N to-be-read words are not cached in the cache device. Reading the command, receiving the N to-be-sent words sent by the memory controller, and sending the N to-be-read words to the processor, and then receiving the N to-be-sents sent by the memory controller A word other than the N words to be read in the memory line to which the word belongs. Since the cache device does not need to acquire other words in the memory row to which the N words to be read belong in the process of acquiring the N words to be read, the delay of reading the N words to be read is not increased, and the existing Compared with the technology, the read delay of the word to be read can be reduced.
图2为本发明内存访问方法实施例二的流程图,如图2所示,本实施例的方法可以包括:2 is a flowchart of Embodiment 2 of a memory access method according to the present invention. As shown in FIG. 2, the method in this embodiment may include:
S201、内存控制器接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字。S201. The memory controller receives N read commands sent by the cache device, where N is an integer greater than or equal to 2. Each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read address. The address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read.
S202、所述内存控制器根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字,并向所述缓存设备发送所述N个待读字。S202. The memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the address of the N to-be-read words, and sends the N to the cache device. The word to be read.
本实施例中,内存控制器根据该N个待读字的地址,确定该N个待读字所属的内存行,再从内存中存储的该N个待读字所属的内存行中获取该N个待读字,并将获取的该N个待读字发送给缓存设备。 In this embodiment, the memory controller determines, according to the address of the N words to be read, the memory line to which the N words to be read belong, and then obtains the N from the memory line to which the N words to be read are stored in the memory. The words to be read are sent to the cache device.
S203、所述内存控制器从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字,并向所述缓存设备发送所述其它字。S203. The memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong, and sends the other words to the cache device.
本实施例中,内存控制器再从内存中存储的该N个待读字所属内存行中获取除该N个待读字之外的其它字,并将获取的这些其它字发送给缓存设备。In this embodiment, the memory controller obtains other words other than the N words to be read from the memory lines of the N to-be-read words stored in the memory, and sends the acquired other words to the cache device.
本实施例中,在内存控制器获取到该N个待读字后,暂时不对该N个待读字所属内存行中除该N个待读字之外的字进行任何处理,而是优先将这N个待读字发送给缓存设备,因此缓存设备在获取这N个待读字时不会受到其它字的读取干扰,从而不会增加缓存设备读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。In this embodiment, after the memory controller obtains the N words to be read, the words other than the N words to be read in the memory line to which the N words to be read are not temporarily processed are not processed, but are preferentially The N words to be read are sent to the cache device, so the cache device does not interfere with the reading of other words when acquiring the N words to be read, thereby not increasing the delay of the cache device reading the N words to be read. Compared with the prior art, the read delay of the word to be read can be reduced.
本发明实施例提供的内存访问方法,通过内存控制器接收缓存设备发送的N个读命令,并根据N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字,并向所述缓存设备优先发送所述N个待读字,然后从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字,并向所述缓存设备发送所述其它字。由于内存控制器在获取这N个待读字的过程中不需要获取这N个待读字所在内存行中的其它字,而且缓存设备在获取这N个待读字时不会受到其它字的读取干扰,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。The memory access method provided by the embodiment of the present invention receives the N read commands sent by the cache device through the memory controller, and obtains the N from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words. Reading the words, and preferentially transmitting the N words to be read to the cache device, and then acquiring words other than the N words to be read from the memory lines to which the N words to be read belong, and The other words are sent to the cache device. Since the memory controller does not need to acquire other words in the memory row of the N words to be read in the process of acquiring the N words to be read, and the cache device does not receive other words when acquiring the N words to be read. The interference is read so that the delay of reading the N words to be read is not increased, and the read delay of the word to be read can be reduced as compared with the prior art.
图3为本发明内存访问方法实施例三的流程图,如图3所示,本实施例的方法可以包括:3 is a flowchart of Embodiment 3 of a memory access method according to the present invention. As shown in FIG. 3, the method in this embodiment may include:
S301、处理器向缓存设备发送N个读命令。S301. The processor sends N read commands to the cache device.
其中,每个读命令包括待读字的地址,每个读命令还可以包括寄存器的标识,具体地,该读命令用于指示将该待读字存储在该处理器的该寄存器中。Each read command includes an address of the word to be read, and each read command may further include an identifier of the register. Specifically, the read command is used to indicate that the word to be read is stored in the register of the processor.
本实施例以N为2进行举例说明,缓存设备会接收处理器发送的2个读命令,如图4所示,这两个读命令例如分别为LoadR0,Addr1+8、LoadR1,addr1+16。这两个读命令分别用于读取同一内存行中的不同的字,LoadR0,Addr1+8用于指示将地址为Addr1的内存行中的地址为8的字存储在寄存器R0中,LoadR1,addr1+16用于指示将地址为Addr1的内存行中的地址为16的字存储在寄存器R1中。In this embodiment, the N is 2, and the cache device receives two read commands sent by the processor. As shown in FIG. 4, the two read commands are, for example, LoadR0, Addr1+8, LoadR1, and addr1+16. These two read commands are used to read different words in the same memory line. LoadR0 and Addr1+8 are used to indicate that the address of the memory line with the address Addr1 is 8 is stored in register R0, LoadR1, addr1 +16 is used to indicate that the word with address 16 in the memory line at address Addr1 is stored in register R1.
S302、所述缓存设备确定未缓存所述N个待读字。S302. The cache device determines that the N to-be-read words are not cached.
S303、所述缓存设备向内存控制器转发该N个读命令。 S303. The cache device forwards the N read commands to the memory controller.
本实施例中,缓存设备接收到上述读命令,判断是否已缓存上述待读字,缓存设备可以根据待读取字的地址,判断是否已缓存该些待读取字,若该缓存设备中已缓存该些待读字,则缓存设备将该些待读字存储在相应的寄存器中,若该缓存设备中未缓存上述两个待读字,即为cache miss,则缓存设备向内存控制器转发该两个读命令;本实施例是以缓存设备未缓存所有待读字为例。若缓存设备中已缓存其中一个待读字,则缓存设备将待读字存储在相应的寄存器中,并且缓存设备向内存控制器发送另一个读命令。In this embodiment, the cache device receives the read command to determine whether the word to be read is cached, and the cache device can determine, according to the address of the word to be read, whether the words to be read have been cached, if the cache device has Cache the words to be read, and the cache device stores the words to be read in the corresponding registers. If the two words to be read are not cached in the cache device, that is, the cache miss, the cache device forwards to the memory controller. The two read commands; this embodiment is an example in which the cache device does not cache all the words to be read. If one of the words to be read has been cached in the cache device, the cache device stores the word to be read in the corresponding register, and the cache device sends another read command to the memory controller.
S304、所述内存控制器根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字。S304. The memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words.
本实施例中,内存控制器根据这两个待读字的地址:Addr1+8和Addr1+16,从地址为Addr1的内存行中优先获取地址为8的待读字和地址为16的待读字。其中,本实施例中的每个待读字存储在该待读字所属内存行的其中一个内存颗粒中。如图5所示,内存控制器中的每个内存行存储有8个字,这8个字分别存储在不同的内存颗粒中,例如:内存行中的字0(表示内存行中的第0个字)存储在内存颗粒0中,内存行中的字1(表示内存行中的第1个字)存储在内存颗粒1中,以此类推,此处不再赘述。具体地,如图4所示,内存控制器可以根据地址Addr1确定待读字所属的内存行,然后根据地址8和地址16,从地址8对应的内存颗粒1获取字1,该字1为待读字,并从地址16对应的内存颗粒2中获取字2,该字2为待读字。In this embodiment, the memory controller preferentially obtains the to-be-read word with address 8 and the address to be read 16 from the memory row with the address Addr1 according to the addresses of the two words to be read: Addr1+8 and Addr1+16. word. Each of the words to be read in the embodiment is stored in one of the memory pixels of the memory line to which the word to be read belongs. As shown in Figure 5, each memory row in the memory controller stores 8 words, which are stored in different memory particles, for example: word 0 in the memory row (representing the 0th in the memory row) The word is stored in the memory particle 0, the word 1 in the memory line (representing the first word in the memory line) is stored in the memory particle 1, and so on, and will not be described here. Specifically, as shown in FIG. 4, the memory controller can determine the memory line to which the word to be read belongs according to the address Addr1, and then obtain the word 1 from the memory particle 1 corresponding to the address 8 according to the address 8 and the address 16, the word 1 is to be The word is read, and word 2 is obtained from the memory particle 2 corresponding to address 16, which is the word to be read.
S305、所述内存控制器向所述缓存设备发送所述N个待读字以及N个待读字的优先级。S305. The memory controller sends the priority of the N to-be-read words and the N to-be-read words to the cache device.
本实施例中,内存控制器在获取到字1和字2这两个待读字后,内存控制器将字1以及字1的优先级,以及字2的优先级。相应地,缓存设备也接收内存控制器发送的字1以及字1的优先级,以及,字2以及字2的优先级。In this embodiment, after the memory controller acquires the two words to be read, the word 1 and the word 2, the memory controller takes the priority of the word 1 and the word 1 and the priority of the word 2. Accordingly, the cache device also receives the priority of word 1 and word 1 transmitted by the memory controller, and the priority of word 2 and word 2.
其中,所述内存控制器根据内存行中所有字的读写频率,确定所有字的优先级,即若字0的读写频率高于字1的读写频率,则字0的优先级高于字1的优先级,如图4所示,内存行中的优先级从高到低的顺序为:字0到字7。The memory controller determines the priority of all words according to the read/write frequency of all words in the memory line, that is, if the read/write frequency of the word 0 is higher than the read/write frequency of the word 1, the priority of the word 0 is higher than The priority of word 1, as shown in Figure 4, the order of priority in the memory line from high to low is: word 0 to word 7.
S306、所述缓存设备向所述处理器发送所述N个待读字。S306. The cache device sends the N to-be-read words to the processor.
具体地,缓存设备可以根据所述寄存器的标识,将每个所述待读字存储在对应的所述处理器的所述寄存器中。缓存设备根据字1携带的字1的地址 (Addr1+8),可以确定对应的读命令为:LoadR0,Addr1+8,然后缓存设备根据R0,将接收到的字1存储在寄存器R0中。缓存设备根据字2携带的字2的地址(Addr1+16),可以确定对应的读命令为:LoadR1,Addr1+16,然后缓存设备根据R1,将接收到的字2存储在寄存器R1中。Specifically, the cache device may store each of the to-be-read words in the corresponding register of the processor according to the identifier of the register. The address of the word 1 carried by the cache device according to word 1 (Addr1+8), it can be determined that the corresponding read command is: LoadR0, Addr1+8, and then the cache device stores the received word 1 in the register R0 according to R0. The cache device can determine that the corresponding read command is: LoadR1, Addr1+16 according to the address of the word 2 carried by the word 2 (Addr1+16), and then the cache device stores the received word 2 in the register R1 according to R1.
S307、所述缓存设备根据所述N个待读字的优先级从高到低的顺序,缓存所述N个待读字。S307. The cache device caches the N to-be-read words according to a priority of the N to-be-read words from high to low.
本实施例中,缓存设备还可以将这两个待读字:字1和字2进行缓存,具体地,缓存设备中的缓存行与内存控制器中的内存行存在对应关系,缓存设备根据字1的地址中的Addr1,确定与地址为Addr1的内存行对应的缓存行,然后根据字1的地址中的地址8,将字1存储在该缓存行地址为8的位置。缓存设备根据字2的地址中的Addr1,确定与地址为Addr1的内存行对应的缓存行,然后根据字2的地址中的地址16,将字2存储在该缓存行地址为16的位置。In this embodiment, the cache device may also cache the two words to be read: word 1 and word 2. Specifically, the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache device is based on the word. Addr1 in the address of 1 determines the cache line corresponding to the memory line of the address Addr1, and then stores the word 1 at the position where the cache line address is 8 according to the address 8 in the address of the word 1. The cache device determines the cache line corresponding to the memory line of the address Addr1 according to Addr1 in the address of the word 2, and then stores the word 2 at the position where the cache line address is 16 according to the address 16 in the address of the word 2.
本实施例中,缓存设备还可以根据字1的优先级高于字2的优先级(如图4所示),先缓存字1再缓存字2。In this embodiment, the cache device may further cache the word 1 and then cache the word 2 according to the priority of the word 1 being higher than the priority of the word 2 (as shown in FIG. 4).
需要说明的是,S306与S307的执行顺序不分先后。It should be noted that the execution order of S306 and S307 is in no particular order.
S308、所述内存控制器从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字。S308. The memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong.
S309、所述内存控制器向所述缓存设备发送所述其它字和所述其它字的优先级。S309. The memory controller sends a priority of the other words and the other words to the cache device.
本实施例中,内存控制器在向缓存设备发送字1以及字2之后,内存控制器再获取字1和字2所属内存行中除该字1和字2之外的字,如内存控制器再获取字0、字3、字4、字5、字6、字7,这些字可以称为预取字,然后向缓存设备发送字0和字0的优先级、字3和字3的优先级、字4和字4的优先级、字5和字5的优先级、字6和字6的优先级、字7和字7的优先级。相应地,缓存设备可以接收内存控制器发送的字0和字0的优先级、字3和字3的优先级、字4和字4的优先级、字5和字5的优先级、字6和字6的优先级、字7和字7的优先级。In this embodiment, after the memory controller sends the word 1 and the word 2 to the cache device, the memory controller acquires words other than the word 1 and the word 2 in the memory line to which the word 1 and the word 2 belong, such as a memory controller. Then obtain word 0, word 3, word 4, word 5, word 6, word 7, these words can be called prefetch words, and then send the priority of word 0 and word 0, the priority of word 3 and word 3 to the cache device. The priority of the level, word 4 and word 4, the priority of word 5 and word 5, the priority of word 6 and word 6, the priority of word 7 and word 7. Correspondingly, the cache device can receive the priority of word 0 and word 0 sent by the memory controller, the priority of word 3 and word 3, the priority of word 4 and word 4, the priority of word 5 and word 5, word 6 And the priority of word 6, the priority of word 7 and word 7.
S310、所述缓存设备根据所述其它字的优先级从高到低的顺序,缓存所述其它字。 S310. The cache device caches the other words according to a priority of the other words from high to low.
本实施例中,缓存设备还可以将除这两个待读字之外的字:字0、字3、字4、字5、字6、字7进行缓存,具体地,缓存设备可以根据字0的地址,确定字0的地址中的Addr1,确定与地址为Addr1的内存行对应的缓存行,然后根据字0的地址中的地址0,将字0存储在该缓存行地址为0的位置。字3、字4、字5、字6、字7的缓存过程类似,此处不再赘述。In this embodiment, the cache device may further cache words other than the two words to be read: word 0, word 3, word 4, word 5, word 6, and word 7. Specifically, the cache device may be based on the word. The address of 0 determines the Addr1 in the address of the word 0, determines the cache line corresponding to the memory line of the address Addr1, and then stores the word 0 at the position where the cache line address is 0 according to the address 0 in the address of the word 0. . The caching process of word 3, word 4, word 5, word 6, and word 7 is similar, and will not be described here.
本实施例中,缓存设备还可以根据优先级从高到低的顺序:字0>字3>字4>字5>字6>字7,缓存各个字,缓存顺序为:字0、字3、字4、字5、字6、字7。In this embodiment, the cache device may also cache the respective words according to the order of priority from high to low: word 0>word 3>word 4>word 5>word 6>word 7, and the cache order is: word 0, word 3 , word 4, word 5, word 6, word 7.
本实施例中,由于内存控制器在获取以及发送这N个待读字的过程中不需要获取和发送这N个待读字所在内存行中的其它字,而且缓存设备在获取这N个待读字的过程中不需要获取这N个待读字所在内存行中的其它字,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。In this embodiment, the memory controller does not need to acquire and send other words in the memory row of the N to-be-read words in the process of acquiring and transmitting the N words to be read, and the cache device is acquiring the N to During the process of reading a word, it is not necessary to obtain other words in the memory row of the N words to be read, so that the delay of reading the N words to be read is not increased, and the word to be read can be reduced compared with the prior art. Read latency.
图6为本发明内存访问方法实施例四的流程图,如图6所示,本实施例的方法在本发明方法实施例一至三或五任一实施例的基础上,进一步地,本实施例的方法还可以包括:FIG. 6 is a flowchart of Embodiment 4 of a memory access method according to the present invention. As shown in FIG. 6, the method in this embodiment is based on any one of Embodiments 1 to 3 or 5 of the method of the present invention, and further, the embodiment is The method can also include:
S401、处理器向缓存设备发送M个写命令。S401. The processor sends M write commands to the cache device.
其中,M为大于或等于1的整数,每个所述写命令包括待写字和所述待写字的地址,所述待写字的地址包括所述待写字所属内存行的地址以及所述待写字写入所属内存行中的地址,所述写命令用于写入所述待写字。Wherein, M is an integer greater than or equal to 1, each of the write commands includes an address to be written and the address to be written, and the address to be written includes an address of the memory row to be written and the writing to be written The address in the belonging memory row, the write command is used to write the to-be-written.
本实施例以M为1进行举例说明,缓存设备会接收处理器发送的1个写命令,如图7所示,这个写命令例如为StoreR0,Addr1+16,Addr1+16表示待写字的地址,即地址为Addr1的内存行中为8的地址,R0表示存储待写字的寄存器,StoreR0,Addr1+16用于指示将寄存器R0中的字存储到地址为Addr1+16的位置。In this embodiment, the M is 1 as an example. The cache device receives a write command sent by the processor. As shown in FIG. 7, the write command is, for example, StoreR0, Addr1+16, and Addr1+16 indicates the address to be written. That is, the address in the memory row of the address Addr1 is 8 address, R0 means to store the register to be written, and StoreR0 and Addr1+16 are used to indicate that the word in the register R0 is stored to the address of the address Addr1+16.
S402、所述缓存设备根据每个所述待写字的地址,将所述每个待写字写入所述每个待写字所属内存行对应缓存行中的相应位置。S402. The cache device writes each of the to-be-written words into a corresponding position in a corresponding cache line of each memory line to be written according to the address to be written.
本实施例中,缓存设备中的缓存行与内存控制器中的内存行存在对应关系,缓存设备根据待写字的地址中的Addr1,确定与地址为Addr1的内存行对应的缓存行,然后根据待写字的地址中的地址16,将待写字存储在该缓存 行地址为16的位置。In this embodiment, the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache device determines the cache line corresponding to the memory line with the address Addr1 according to Addr1 in the address to be written, and then according to the Address 16, in the address of the letter, stores the word to be written in the cache The row address is 16 locations.
S403、所述缓存设备向所述内存控制器转发M个写命令。S403. The cache device forwards M write commands to the memory controller.
本实施例中,缓存设备可以根据这个写命令,判断是否已缓存地址为Addr1的内存行,若已缓存,则执行S406,若未缓存,则缓存设备内存控制器转发写命令。本实施例是以缓存设备中未缓存待写字所属内存行为例进行说明。In this embodiment, the cache device may determine, according to the write command, whether the memory line with the address of Addr1 is cached. If it is cached, execute S406. If not, the cache device memory controller forwards the write command. This embodiment is described as an example of a memory behavior of a cache device that is not cached to be written.
S404、所述内存控制器根据所述写命令,向所述缓存设备发送所述M个待写字所属内存行中除所述M个待写字的地址所对应的字之外的其它字。S404, the memory controller sends, according to the write command, a word other than the word corresponding to the M addresses to be written in the M memory lines to be written to the cache device.
本实施例中,内存控制器接收缓存设备发送的包括待写字的地址的写命令,内存控制器可以根据该写命令,停止获取该待写字的地址所对应的字,而获取该待写字所属内存行中除待写字的地址所对应的字之外的字,本实施例中是获取地址为Addr1的内存行中除字2(地址为16所对应的字)之外的其它字,这些字为字0、字1、字3、字4、字5、字6、字7,这些字也可以称为预取字,然后向缓存设备发送字0和字0的地址(Addr1+0)、字1和字1的地址(Addr1+8)、字3和字3的地址(Addr1+24)、字4和字4的地址(Addr1+32)、字5和字5的地址(Addr1+40)、字6和字6的地址(Addr1+48)、字7和字7的地址(Addr1+56)。相应地,缓存设备可以接收内存控制器发送的上述字。In this embodiment, the memory controller receives a write command that is sent by the cache device, including the address to be written, and the memory controller may stop acquiring the word corresponding to the address to be written according to the write command, and obtain the memory to be written. In addition to the word corresponding to the word to be written in the line, in this embodiment, the word other than word 2 (the word corresponding to the address 16) in the memory line with the address Addr1 is obtained, and these words are Word 0, word 1, word 3, word 4, word 5, word 6, word 7, these words can also be called prefetch words, and then send the address of word 0 and word 0 (Addr1+0), word to the cache device Address of 1 and word 1 (Addr1+8), address of word 3 and word 3 (Addr1+24), address of word 4 and word 4 (Addr1+32), address of word 5 and word 5 (Addr1+40) , the address of Word 6 and Word 6 (Addr1+48), the address of Word 7 and Word 7 (Addr1+56). Accordingly, the cache device can receive the above words sent by the memory controller.
可选地,内存控制器可以将字0和字0的优先级,字1和字1的优先级,字3和字3的优先级,字4和字4的优先级、字5和字5的优先级、字6和字6的优先级、字7和字7的优先级发送给缓存设备。Alternatively, the memory controller can prioritize word 0 and word 0, priority of word 1 and word 1, priority of word 3 and word 3, priority of word 4 and word 4, word 5 and word 5 The priority, the priority of word 6 and word 6, the priority of word 7 and word 7 are sent to the cache device.
S405、所述缓存设备缓存所述M个待写字所属内存行中除所述M个待写字的地址所对应的字之外的其它字。S405. The cache device caches words other than words corresponding to the M addresses to be written in the M memory lines to be written.
本实施例中,缓存设备可以将接收到的内存控制器发送的字0、字1、字3、字4、字5、字6、字7进行缓存。具体地,缓存设备可以根据字0的地址,确定字0的地址中的Addr1,确定与地址为Addr1的内存行对应的缓存行,然后根据字0的地址中的地址0,将字0存储在该缓存行地址为0的位置。字1、字3、字4、字5、字6、字7的缓存过程类似,此处不再赘述。In this embodiment, the cache device may cache the word 0, word 1, word 3, word 4, word 5, word 6, and word 7 sent by the received memory controller. Specifically, the cache device may determine Addr1 in the address of the word 0 according to the address of the word 0, determine a cache line corresponding to the memory line of the address Addr1, and then store the word 0 according to the address 0 in the address of the word 0. The location where the cache line address is 0. The caching process of word 1, word 3, word 4, word 5, word 6, and word 7 is similar, and will not be described here.
可选地,缓存设备还可以根据优先级从高到低的顺序:字0>字1>字3>字4>字5>字6>字7,缓存各个字,缓存顺序为:字0、字1、字3、字4、字 5、字6、字7。Optionally, the cache device may also cache the individual words according to the order of priority from high to low: word 0>word 1>word 3>word 4>word 5>word 6>word 7. The cache order is: word 0, Word 1, word 3, word 4, word 5. Word 6, word 7.
S406、所述缓存设备向所述内存控制器发送所述M个待写字所属内存行对应的缓存行。S406. The cache device sends, to the memory controller, a cache line corresponding to the M memory lines to be written.
本实施例中,缓存设备在缓存好上述内存行中的所有字之后,缓存设备向内存控制器发送待写字所属内存行对应的缓存行,即缓存设备将字0、字1、待写字、字3、字4、字5、字6、字7发送给内存控制器。In this embodiment, after the cache device caches all the words in the memory row, the cache device sends a cache line corresponding to the memory row to be written to the memory controller, that is, the cache device uses the word 0, the word 1, the word to be written, and the word. 3. Word 4, Word 5, Word 6, and Word 7 are sent to the memory controller.
S407、所述内存控制器将所述M个待写字所属内存行分别改写为所述M个待写字所属内存行对应的缓存行。S407. The memory controller rewrites the M memory lines to be written into the cache lines corresponding to the M memory lines to be written.
本实施例中,内存控制器接收缓存设备发送的待写字所属内存行对应的缓存行,内存控制器将地址为Addr1的内存行改写为接收的缓存设备发送的缓存行,即将地址为Addr1的内存行中的所有字改写为字0、字1、待写字、字3、字4、字5、字6、字7,从而实现字的改写过程。In this embodiment, the memory controller receives the cache line corresponding to the memory line to be written by the cache device, and the memory controller rewrites the memory line with the address Addr1 to the cache line sent by the received cache device, that is, the memory with the address Addr1. All words in the line are rewritten as word 0, word 1, to be written, word 3, word 4, word 5, word 6, word 7, thereby realizing the word rewriting process.
本实施例中,由于内存控制器接收到写命令后,不需要将整个内存行中的所有字发送给缓存设备,从而可以节省开销。In this embodiment, since the memory controller does not need to send all the words in the entire memory row to the cache device after receiving the write command, the overhead can be saved.
图8为本发明内存访问方法实施例五的流程图,如图8所示,本实施例的方法可以包括:FIG. 8 is a flowchart of Embodiment 5 of the memory access method of the present invention. As shown in FIG. 8, the method in this embodiment may include:
S501、处理器向缓存设备发送N个读命令。S501. The processor sends N read commands to the cache device.
其中,N为大于或等于2的整数,每个读命令包括待读字的地址和寄存器的标识,该读命令用于指示将该待读字存储在该寄存器中。Where N is an integer greater than or equal to 2, each read command includes an address of the word to be read and an identifier of the register, the read command is used to indicate that the word to be read is stored in the register.
本实施例以N为3进行举例说明,缓存设备会接收处理器发送的3个读命令,如图9所示,这3个读命令例如分别为LoadR0,Addr0+16、LoadR1,addr1+32、LoadR1,addr2+48,这3个读命令分别用于读取不同内存行中的字,LoadR0,Addr0+16用于指示将地址为Addr0的内存行中的地址为16的字存储在寄存器R0中,LoadR1,addr1+32用于指示将地址为Addr1的内存行中的地址为32的字存储在寄存器R1中,LoadR2,addr2+48用于指示将地址为Addr2的内存行中的地址为48的字存储在寄存器R2中。In this embodiment, the N is 3, and the cache device receives three read commands sent by the processor. As shown in FIG. 9, the three read commands are, for example, LoadR0, Addr0+16, LoadR1, and addr1+32. LoadR1, addr2+48, these three read commands are used to read the words in different memory lines, LoadR0, Addr0+16 is used to indicate that the address of the memory line with the address Addr0 is 16 is stored in register R0. , LoadR1, addr1+32 are used to indicate that the address of the memory line with the address Addr1 is 32 is stored in the register R1, and LoadR2, addr2+48 is used to indicate that the address in the memory line with the address Addr2 is 48. The word is stored in register R2.
S502、所述缓存设备确定未缓存所述N个待读字。S502. The cache device determines that the N to-be-read words are not cached.
S503、所述缓存设备向内存控制器转发所述N个读命令。S503. The cache device forwards the N read commands to a memory controller.
本实施例中,缓存设备接收到上述读命令,判断是否已缓存上述待读字,缓存设备可以根据待读取字的地址,判断是否已缓存该待读取字,若该缓存 设备中已缓存该待读字,则缓存设备将该待读字存储在相应的寄存器中,若该缓存设备中未缓存上述3个待读字,即为cache miss,则缓存设备向内存控制器转发该3个读命令;本实施例是以缓存设备未缓存所有待读字为例。In this embodiment, the cache device receives the read command to determine whether the word to be read has been cached, and the cache device can determine, according to the address of the word to be read, whether the word to be read is cached, if the cache If the word to be read is cached in the device, the cache device stores the word to be read in the corresponding register. If the three words to be read are not cached in the cache device, that is, the cache miss, the cache device is directed to the memory controller. The three read commands are forwarded; this embodiment is an example in which the cache device does not cache all the words to be read.
S504、所述内存控制器根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字。S504. The memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words.
本实施例中,内存控制器根据这3个待读字的地址:Addr0+16、Addr1+32、Addr2+48,从地址为Addr0的内存行中优先获取地址为16的待读字、从地址为Addr1的内存行中优先获取地址为32的待读字、从地址为Addr2的内存行中优先获取地址为48的待读字。而且,内存控制器根据这个待写字的地址:Addr3+56,停止从地址为Addr3的内存行中获取地址为56的字,其中,本实施例中的每个字存储在该字所属内存行的其中一个内存颗粒中。如图9所示,内存控制器中的每个内存行存储有8个字,这8个字分别存储在不同的内存颗粒中,例如:内存行0中的字00(表示内存行0中的第0个字)存储在内存颗粒0中,内存行1中的字11(表示内存行1中的第1个字)存储在内存颗粒1中,以此类推,此处不再赘述。其中,字00、字10、字20存储在内存颗粒0中,字01、字11、字21存储在内存颗粒1中,以此类推,此处不再赘述。具体地,如图9所示,内存控制器可以根据地址Addr0确定待读字所属的内存行0,然后根据地址16,从地址16对应的内存颗粒2中获取字02,该字02为待读字;内存控制器可以根据地址Addr1确定待读字所属的内存行1,然后根据地址32,从地址32对应的内存颗粒4中获取字14,该字14为待读字;内存控制器可以根据地址Addr2确定待读字所属的内存行2,然后根据地址48,从地址48对应的内存颗粒6中获取字26,该字26为待读字。In this embodiment, the memory controller preferentially obtains the to-be-read word and the slave address with the address of 16 from the memory row with the address Addr0 according to the addresses of the three words to be read: Addr0+16, Addr1+32, and Addr2+48. For the memory line of Addr1, the word to be read with the address of 32 is preferentially obtained, and the word to be read with the address of 48 is preferentially obtained from the memory line with the address of Addr2. Moreover, the memory controller stops acquiring the word of the address 56 from the memory line of the address Addr3 according to the address to be written: Addr3+56, wherein each word in the embodiment is stored in the memory line of the word. One of the memory particles. As shown in Figure 9, each memory row in the memory controller stores 8 words, which are stored in different memory particles, for example, word 00 in memory row 0 (representing memory row 0) The 0th word is stored in the memory granule 0, the word 11 in the memory line 1 (representing the first word in the memory line 1) is stored in the memory granule 1, and so on, and will not be described again here. The word 00, the word 10, and the word 20 are stored in the memory granule 0, and the word 01, the word 11, and the word 21 are stored in the memory granule 1, and so on, and are not described herein again. Specifically, as shown in FIG. 9, the memory controller can determine the memory line 0 to which the word to be read belongs according to the address Addr0, and then obtain the word 02 from the memory particle 2 corresponding to the address 16 according to the address 16, the word 02 is to be read. The memory controller can determine the memory line 1 to which the word to be read belongs according to the address Addr1, and then obtain the word 14 from the memory particle 4 corresponding to the address 32 according to the address 32, the word 14 is the word to be read; the memory controller can be based on The address Addr2 determines the memory line 2 to which the word to be read belongs, and then obtains the word 26 from the memory grain 6 corresponding to the address 48 according to the address 48, which is the word to be read.
S505、所述内存控制器向所述缓存设备发送所述N个待读字和所述N个待读字的优先级。S505. The memory controller sends the priority of the N to-be-read words and the N to-be-read words to the cache device.
本实施例中,内存控制器在获取到字02、字14和字26这3个待读字后,内存控制器将字01、字01的优先级、字14和字14的优先级、字26和字26的优先级发送给缓存设备,使得缓存设备根据字01的地址、字14的地址、字26的地址可以区分接收到的这3个字分别为哪一个读命令所需要获取的字。需要说明的是,与现有技术类似,上述各个字均会携带各个字的地址。 In this embodiment, after the memory controller acquires the three words to be read, namely word 02, word 14 and word 26, the memory controller sets the priority of word 01, word 01, the priority of word 14 and word 14, and the word. The priority of 26 and the word 26 is sent to the cache device, so that the cache device can distinguish which of the received three words is the word to be read according to the address of the word 01, the address of the word 14, and the address of the word 26. . It should be noted that, similar to the prior art, each of the above words carries the address of each word.
S506、所述缓存设备向所述处理器发送所述N个待读字。S506. The cache device sends the N to-be-read words to the processor.
本实施例中,缓存设备根据所述寄存器的标识,将每个所述待读字存储在对应的所述寄存器中。如,缓存设备根据字02的地址(Addr0+16),可以确定对应的读命令为:LoadR0,Addr0+16,然后缓存设备根据R0,将接收到的字02存储在寄存器R0中。缓存设备根据字14的地址(Addr1+32),可以确定对应的读命令为:LoadR1,Addr1+32,然后缓存设备根据R1,将接收到的字14存储在寄存器R1中。缓存设备根据字26的地址(Addr1+32),可以确定对应的读命令为:LoadR2,Addr2+48,然后缓存设备根据R2,将接收到的字26存储在寄存器R2中。In this embodiment, the cache device stores each of the words to be read in the corresponding register according to the identifier of the register. For example, the cache device can determine that the corresponding read command is: LoadR0, Addr0+16 according to the address of the word 02 (Addr0+16), and then the cache device stores the received word 02 in the register R0 according to R0. Based on the address of the word 14 (Addr1+32), the cache device can determine that the corresponding read command is: LoadR1, Addr1+32, and then the cache device stores the received word 14 in the register R1 according to R1. Based on the address of word 26 (Addr1+32), the cache device can determine that the corresponding read command is: LoadR2, Addr2+48, and then the cache device stores the received word 26 in register R2 according to R2.
S507、所述缓存设备根据所述N个待读字的优先级从高到低的顺序,缓存所述N个待读字。S507. The cache device caches the N to-be-read words according to an order of priority of the N to-be-read words.
本实施例中,缓存设备还可以将这3个待读字:字02、字14和字26进行缓存,具体地,缓存设备中的缓存行与内存控制器中的内存行存在对应关系,缓存设备根据字02的地址中的Addr0,确定与地址为Addr0的内存行0对应的缓存行0,然后根据字02的地址中的地址16,将字02存储在该缓存行0地址为16的位置。缓存设备根据字14的地址中的Addr1,确定与地址为Addr1的内存行1对应的缓存行1,然后根据字14的地址中的地址32,将字14存储在该缓存行1地址为32的位置。缓存设备根据字26的地址中的Addr2,确定与地址为Addr2的内存行2对应的缓存行2,然后根据字26的地址中的地址48,将字26存储在该缓存行2地址为48的位置。In this embodiment, the cache device may also cache the three words to be read: word 02, word 14, and word 26. Specifically, the cache line in the cache device has a corresponding relationship with the memory line in the memory controller, and the cache The device determines the cache line 0 corresponding to the memory line 0 of the address Addr0 according to Addr0 in the address of the word 02, and then stores the word 02 in the position of the cache line 0 address 16 according to the address 16 in the address of the word 02. . The cache device determines the cache line 1 corresponding to the memory line 1 of the address Addr1 according to Addr1 in the address of the word 14, and then stores the word 14 in the cache line 1 address 32 according to the address 32 in the address of the word 14. position. The cache device determines the cache line 2 corresponding to the memory line 2 of the address Addr2 according to Addr2 in the address of the word 26, and then stores the word 26 in the cache line 2 address 48 according to the address 48 in the address of the word 26. position.
如图9所示,缓存设备还可以根据26的优先级高于字14的优先级,字14的优先级高于字02的优先级,先缓存字26,再缓存字14,然后缓存字02。As shown in FIG. 9, the cache device may also have a priority higher than the priority of the word 14 according to the priority of the word 14, the priority of the word 14 is higher than the priority of the word 02, the word 26 is cached first, then the word 14 is cached, and then the word 02 is cached. .
需要说明的是,S506与S507的执行顺序不分先后。It should be noted that the execution order of S506 and S507 is in no particular order.
S508、所述内存控制器从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字。S508. The memory controller acquires words other than the N to-be-read words from the memory lines to which the N to-be-read words belong.
S509、所述内存控制器根据所述N个待读字所属内存行中属于同一内存颗粒的除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字以及所述其它字的优先级。S509, the memory controller according to the order of priority of each word except the N to-be-read words belonging to the same memory particle in the memory line to which the N to-be-read words belong, to the The cache device transmits the priority of the other words and the other words.
本实施例中,内存控制器在获取字02,字14以及字26之后,内存控制器再获取字02所属内存行0中除该字02之外的字、字14所属内存行1中除 该字14之外的字、字26所属内存行2中除该字26之外的字,这些字可以称为预取字,然后向缓存设备发送这些字和这些字的地址。相应地,缓存设备可以接收内存控制器发送的这些字和这些字的地址。In this embodiment, after the memory controller acquires the word 02, the word 14 and the word 26, the memory controller acquires the word in the memory line 0 of the word 02, except the word 02, and the memory line 1 of the word 14 belongs to Words other than the word 14, words 26 of the memory line 2 other than the word 26, which may be referred to as prefetched words, are then sent to the cache device for the words and the addresses of the words. Accordingly, the cache device can receive the words sent by the memory controller and the addresses of the words.
本实施例中,所述内存控制器可以根据属于同一内存颗粒的各个字的优先级从高至低的顺序,向所述缓存设备发送该N个待读字所属内存行中除N个待读字之外的其它字。针对内存颗粒0,内存控制器向缓存设备依次发送字20、字10、字00。针对内存颗粒1,内存控制器向缓存设备依次发送字21、字11、字01。针对内存颗粒2,内存控制器向缓存设备依次发送字22、字12。针对内存颗粒3,内存控制器向缓存设备依次发送字23、字13、字03。针对内存颗粒4,内存控制器向缓存设备依次发送字24、字04。针对内存颗粒5,内存控制器向缓存设备依次发送字25、字15、字05。针对内存颗粒6,内存控制器向缓存设备依次发送字16、字06。针对内存颗粒7,内存控制器向缓存设备依次发送字27、字17、字07。In this embodiment, the memory controller may send, to the cache device, the N to-be-read words in the memory row to which the N words to be read belong according to the priority of the respective words belonging to the same memory particle from high to low. Other words than words. For memory granule 0, the memory controller sequentially sends word 20, word 10, and word 00 to the cache device. For the memory granule 1, the memory controller sequentially sends the word 21, the word 11, and the word 01 to the cache device. For the memory granule 2, the memory controller sequentially sends the word 22, word 12 to the cache device. For the memory granule 3, the memory controller sequentially sends the word 23, word 13, and word 03 to the cache device. For the memory granule 4, the memory controller sequentially sends the word 24, word 04 to the cache device. For the memory granule 5, the memory controller sequentially sends the word 25, word 15, and word 05 to the cache device. For the memory granule 6, the memory controller sequentially sends the word 16, word 06 to the cache device. For memory particles 7, the memory controller sequentially sends word 27, word 17, word 07 to the cache device.
若内存控制器可以同时向缓存设备发送8个字,则内存控制器首先向缓存设备发送字27、字26、字25、字14、字23、字02、字21、字20,再发送字17、字16、字15、字24、字13、字22、字11、字10,再发送字07、字06、字05、字04、字03、字12、字01、字00。If the memory controller can simultaneously send 8 words to the cache device, the memory controller first sends word 27, word 26, word 25, word 14, word 23, word 02, word 21, word 20 to the cache device, and then sends the word. 17. Word 16, Word 15, Word 24, Word 13, Word 22, Word 11, Word 10, and then send word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
若内存控制器同时可以向缓存设备发送少于8个字,则内存控制器首先根据优先级从高到低的顺序,向缓存设备发送字26、字14、字02、字27、字25、字23、字21、字20;再根据优先级从高到低的顺序,发送字17、字16、字15、字24、字13、字22、字11、字10,再根据优先级从高到低的顺序,发送字07、字06、字05、字04、字03、字12、字01、字00。If the memory controller can send less than 8 words to the cache device at the same time, the memory controller first sends the word 26, the word 14, the word 02, the word 27, the word 25, to the cache device according to the order of priority from high to low. Word 23, word 21, word 20; then send word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10 according to the order of priority from high to low, and then according to the priority In the high to low order, word 07, word 06, word 05, word 04, word 03, word 12, word 01, and word 00 are transmitted.
若内存控制器同时可以向缓存设备发送少于8个字,则内存控制器可以先发送字26、字14、字02,再根据优先级从高到低的顺序,向缓存设备发送:字27、字25、字23、字21、字20、字17、字16、字15、字24、字13、字22、字11、字10、字07、字06、字05、字04、字03、字12、字01、字00。If the memory controller can send less than 8 words to the cache device at the same time, the memory controller can first send the word 26, the word 14, the word 02, and then send the word to the cache device according to the order of priority from high to low: word 27 , word 25, word 23, word 21, word 20, word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10, word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
本实施例中,内存控制器还可以将上述各个字的优先级也发送给缓存设备。In this embodiment, the memory controller may also send the priority of each of the above words to the cache device.
S510、所述缓存设备根据所述其它字的优先级从高到低的顺序,缓存所 述其它字。S510. The cache device caches the order according to the priority of the other words from high to low. Said other words.
本实施例中,缓存设备根据所述其它字的地址,将所述其它字缓存至所述其它字所属内存行对应缓存行中的相应位置。例如,根据字07的地址中的地址40,将字07存储在该缓存行0地址为56的位置。其它字的缓存过程类似,此处不再赘述。In this embodiment, the cache device caches the other words to corresponding locations in the cache line corresponding to the memory lines to which the other words belong according to the addresses of the other words. For example, word 07 is stored at the location where the cache line 0 address is 56, based on address 40 in the address of word 07. The caching process for other words is similar and will not be described here.
缓存设备还可以根据S509中所述的各个字的优先级从高到低的顺序,缓存上述各个字,例如:缓存设备先根据优先级从高到低的顺序,缓存字27、字25、字23、字21、字20;再根据优先级从高到低的顺序,缓存字17、字16、字15、字24、字13、字22、字11、字10;再根据优先级从高到低的顺序,缓存字07、字06、字05、字04、字03、字12、字01、字00。The cache device may also cache the above words according to the priority of each word described in S509 from high to low. For example, the cache device first caches the word 27, the word 25, and the word according to the order of priority from high to low. 23, word 21, word 20; according to the order of priority from high to low, cache word 17, word 16, word 15, word 24, word 13, word 22, word 11, word 10; then according to the priority from high In the low order, cache word 07, word 06, word 05, word 04, word 03, word 12, word 01, word 00.
本实施例中,由于内存控制器在获取以及发送这N个待读字的过程中不需要获取和发送这N个待读字所在内存行中的其它字,而且缓存设备在获取这N个待读字的过程中不需要获取这N个待读字所在内存行中的其它字,从而不会增加读取该N个待读字的时延,与现有技术相比,可以降低待读字的读取时延。同时由于内存控制器接收到第二写命令后,不需要将整个内存行中的所有字发送给缓存设备,从而可以节省开销。In this embodiment, the memory controller does not need to acquire and send other words in the memory row of the N to-be-read words in the process of acquiring and transmitting the N words to be read, and the cache device is acquiring the N to During the process of reading a word, it is not necessary to obtain other words in the memory row of the N words to be read, so that the delay of reading the N words to be read is not increased, and the word to be read can be reduced compared with the prior art. Read latency. At the same time, since the memory controller receives the second write command, it does not need to send all the words in the entire memory row to the cache device, thereby saving the overhead.
图10为本发明缓存设备实施例一的结构示意图,如图10所示,本实施例的缓存设备包括:接收单元11、处理单元12和发送单元13;其中,接收单元11,用于接收处理器发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;处理单元12,用于确定所述缓存设备中是否缓存所述N个待读字;发送单元13,用于当处理单元12确定所述缓存设备中未缓存所述N个待读字时,向内存控制器转发所述N个读命令;接收单元11,还用于接收所述内存控制器发送的所述N个待读字,以及发送单元13,还用于向所述处理器发送所述N个待读字;接收单元11,还用于接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。10 is a schematic structural diagram of Embodiment 1 of a cache device according to the present invention. As shown in FIG. 10, the cache device of this embodiment includes: a receiving unit 11, a processing unit 12, and a sending unit 13; wherein, the receiving unit 11 is configured to receive processing. N read commands sent by the device, the N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes an address of a memory line to which the word to be read belongs And the address of the word to be read in the memory line, the read command is used to read the word to be read; the processing unit 12 is configured to determine whether the N words to be read are cached in the cache device The sending unit 13 is configured to: when the processing unit 12 determines that the N words to be read are not cached in the cache device, forward the N read commands to the memory controller; the receiving unit 11 is further configured to receive the The N words to be read sent by the memory controller, and the sending unit 13 are further configured to send the N to be read words to the processor; the receiving unit 11 is further configured to receive the sending by the memory controller The N waiting to be read in the memory line to which the word to be read belongs Read words other than words.
可选地,接收单元11用于接收所述内存控制器发送的第一字,包括:接收单元11用于,接收所述内存控制器发送的所述第一字和所述第一字的优先级;处理单元12,还用于根据所述第一字的优先级从高到低的顺序,缓存所 述第一字;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。Optionally, the receiving unit 11 is configured to receive the first word sent by the memory controller, where the receiving unit 11 is configured to receive the first word and the first word sent by the memory controller. The processing unit 12 is further configured to cache the location according to the priority of the first word from high to low. a first word; wherein the first word is a word other than the N to-be-read words in the memory line to which the N to-be-read words or the N to-be-read words belong.
本实施例的缓存设备,可以用于执行本发明上述方法实施例中缓存设备所执行的技术方案,其实现原理和技术效果类似,此处不再赘述。The cache device of this embodiment may be used to perform the technical solution executed by the cache device in the foregoing method embodiment of the present invention. The implementation principle and technical effects are similar, and details are not described herein again.
图11为本发明内存控制器实施例一的结构示意图,如图11所示,本实施例的内存控制器包括:接收单元21、处理单元22和发送单元23;其中,接收单元21,用于接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;处理单元22,用于根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字;发送单元23,用于向所述缓存设备发送所述N个待读字;处理单元22,还用于从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字;发送单元23,还用于向所述缓存设备发送所述其它字。FIG. 11 is a schematic structural diagram of Embodiment 1 of a memory controller according to the present invention. As shown in FIG. 11, the memory controller of this embodiment includes: a receiving unit 21, a processing unit 22, and a sending unit 23; wherein, the receiving unit 21 is configured to Receiving N read commands sent by the cache device, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and an address of the word to be read includes an memory line to which the word to be read belongs And an address of the word to be read in the memory line, the read command is used to read the word to be read, and the processing unit 22 is configured to: according to the address of the N words to be read, Obtaining the N to-be-read words in the memory row to which the N words to be read belong; the sending unit 23 is configured to send the N to-be-read words to the cache device; the processing unit 22 is further configured to use the N The words in the memory line to which the word to be read belong are obtained other than the N words to be read; the sending unit 23 is further configured to send the other words to the cache device.
可选地,发送单元23用于向所述缓存设备发送所述其它字,包括:发送单元23用于根据所述N个待读字所属内存行中属于同一内存颗粒的除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字。Optionally, the sending unit 23 is configured to send the other words to the cache device, where: the sending unit 23 is configured to: according to the N memory cells belonging to the same memory particle in the memory row to which the N to be read words belong The other words are transmitted to the cache device in a descending order of priority of the words other than the read word.
可选地,发送单元23用于向所述缓存设备发送第一字,包括:发送单元23用于,向所述缓存设备发送所述第一字和所述第一字的优先级;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。Optionally, the sending unit 23 is configured to send the first word to the cache device, where the sending unit 23 is configured to send, to the cache device, a priority of the first word and the first word, where The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
可选地,处理单元22,还用于发送单元23向所述缓存设备发送所述第一字之前,根据所述N个待读字所属内存行中各个字的读写频率,确定所述各个字的优先级。Optionally, the processing unit 22 is further configured to: before the transmitting unit 23 sends the first word to the cache device, determine, according to the read/write frequency of each word in the memory line to which the N to-be-read words belong, The priority of the word.
可选地,所述N个待读字所属内存行中的每个字存储在一个内存颗粒中。Optionally, each word in the memory row to which the N words to be read belong is stored in one memory particle.
本实施例的内存控制器,可以用于执行本发明上述方法实施例中内存控制器所执行的技术方案,其实现原理和技术效果类似,此处不再赘述。The memory controller of this embodiment may be used to perform the technical solution executed by the memory controller in the foregoing method embodiment of the present invention, and the implementation principle and technical effects thereof are similar, and details are not described herein again.
图12为本发明计算机设备实施例一的结构示意图,如图12所示,本实施例的计算机设备,本实施例提供的计算机设备700可以是包含计算能力 的主机服务器,或者是个人计算机(英文:Personal Computer,简称:PC),或者是可携带的便携式计算机或终端等,本发明在此不做限制,本发明具体实施例并不对计算机设备700的具体实现做限定。计算机设备700可以包括:缓存设备710、内存控制器720、处理器(Processor)730、内存设备740;该计算机设备700还可以包括:通信总线750,其中,缓存设备710、内存控制器720、处理器730、内存设备740可以通过通信总线750完成各设备之间的通信。该计算机设备700还可以包括通信接口760,处理器730可以通过通信接口760与外部设备进行通信。FIG. 12 is a schematic structural diagram of Embodiment 1 of a computer device according to the present invention. As shown in FIG. 12, the computer device provided in this embodiment may include computing capability. The host server, or a personal computer (English: Personal Computer, PC for short), or a portable computer or terminal, etc., the present invention is not limited thereto, and the specific embodiment of the present invention is not specific to the computer device 700. Realization is limited. The computer device 700 may include: a cache device 710, a memory controller 720, a processor 730, and a memory device 740; the computer device 700 may further include: a communication bus 750, wherein the cache device 710, the memory controller 720, and the processing The memory device 730 and the memory device 740 can complete communication between the devices through the communication bus 750. The computer device 700 can also include a communication interface 760 through which the processor 730 can communicate with external devices.
其中,缓存设备710可以采用如图10所示的结构,其对应地,可以执行本发明上述方法实施例中缓存设备所执行的技术方案,此处不再赘述;内存控制器720可以采用如图11所示的结构,可以执行本发明上述方法实施例中内存控制器所执行的执行方案,此处不再赘述。The cache device 710 can adopt the structure shown in FIG. 10, and correspondingly, the technical solution executed by the cache device in the foregoing method embodiment of the present invention can be executed, and details are not described herein; the memory controller 720 can be configured as shown in the figure. The configuration shown in FIG. 11 can perform the execution scheme executed by the memory controller in the foregoing method embodiment of the present invention, and details are not described herein again.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:只读内存(英文:Read-Only Memory,简称:ROM)、随机存取存储器(英文:Random Access Memory,简称:RAM)、磁碟或者光盘等各种可以存储程序代码的介质。A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to the program instructions. The foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing storage medium includes: read-only memory (English: Read-Only Memory, ROM for short), random access memory (English: Random Access Memory, RAM), disk or A variety of media such as optical discs that can store program code.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims (15)

  1. 一种内存访问方法,其特征在于,包括:A memory access method, comprising:
    缓存设备接收处理器发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;The cache device receives N read commands sent by the processor, the N is an integer greater than or equal to 2, the read command includes an address of the word to be read, and the address of the word to be read includes the word to be read An address of the memory line and an address of the word to be read in the memory line, the read command is used to read the word to be read;
    当所述缓存设备中未缓存所述N个待读字时,所述缓存设备向内存控制器转发所述N个读命令;When the N words to be read are not cached in the cache device, the cache device forwards the N read commands to the memory controller;
    所述缓存设备接收所述内存控制器发送的所述N个待读字,以及向所述处理器发送所述N个待读字;The cache device receives the N to-be-sent words sent by the memory controller, and sends the N to-be-read words to the processor;
    所述缓存设备接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。The cache device receives other words in the memory row to which the N words to be read are sent by the memory controller, except the N to-be-read words.
  2. 根据权利要求1所述的方法,其特征在于,所述缓存设备接收所述内存控制器发送的第一字,包括:The method according to claim 1, wherein the buffering device receives the first word sent by the memory controller, including:
    所述缓存设备接收所述内存控制器发送的所述第一字和所述第一字的优先级;Receiving, by the cache device, a priority of the first word and the first word sent by the memory controller;
    所述方法,还包括:The method further includes:
    所述缓存设备根据所述第一字的优先级从高到低的顺序,缓存所述第一字;The cache device caches the first word according to a priority of the first word from high to low;
    其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
  3. 一种内存访问方法,其特征在于,包括:A memory access method, comprising:
    内存控制器接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;The memory controller receives N read commands sent by the cache device, the N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the word to be read An address of the associated memory line and an address of the word to be read in the memory line, the read command is used to read the word to be read;
    所述内存控制器根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字,并向所述缓存设备发送所述N个待读字;The memory controller acquires the N to-be-read words from the memory lines to which the N to-be-read words belong according to the address of the N words to be read, and sends the N to be read to the cache device. word;
    所述内存控制器从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字,并向所述缓存设备发送所述其它字。The memory controller acquires words other than the N to-be-read words from the memory lines to which the N words to be read belong, and sends the other words to the cache device.
  4. 根据权利要求3所述的方法,其特征在于,所述内存控制器向所述缓 存设备发送所述其它字,包括:The method of claim 3 wherein said memory controller is responsive to said The storage device sends the other words, including:
    所述内存控制器根据所述N个待读字所属内存行中属于同一内存颗粒的除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字。The memory controller sends the cache device to the cache device according to the priority of each of the N memory words belonging to the same memory particle belonging to the same memory particle from the highest to the lowest according to the N memory strings to be read. Send the other words.
  5. 根据权利要求3或4所述的方法,其特征在于,所述内存控制器向所述缓存设备发送第一字,包括:The method according to claim 3 or 4, wherein the memory controller sends the first word to the cache device, including:
    所述内存控制器向所述缓存设备发送所述第一字和所述第一字的优先级;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The memory controller sends a priority of the first word and the first word to the cache device, where the first word is the N words to be read or the N words to be read belong to A word other than the N words to be read in the memory line.
  6. 根据权利要求5所述的方法,其特征在于,所述内存控制器向所述缓存设备发送所述第一字之前,还包括:The method according to claim 5, wherein before the memory controller sends the first word to the cache device, the method further includes:
    所述内存控制器根据所述N个待读字所属内存行中各个字的读写频率,确定所述各个字的优先级。The memory controller determines the priority of each word according to the read/write frequency of each word in the memory line to which the N words to be read belong.
  7. 根据权利要求3-6任意一项所述的方法,其特征在于,所述N个待读字所属内存行中的每个字存储在一个内存颗粒中。The method according to any one of claims 3-6, wherein each of the memory lines to which the N words to be read belong is stored in a memory particle.
  8. 一种缓存设备,其特征在于,包括:A cache device, comprising:
    接收单元,用于接收处理器发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;a receiving unit, configured to receive N read commands sent by the processor, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
    处理单元,用于确定所述缓存设备中是否缓存所述N个待读字;a processing unit, configured to determine whether the N to-be-read words are cached in the cache device;
    发送单元,用于当所述处理单元确定所述缓存设备中未缓存所述N个待读字时,向内存控制器转发所述N个读命令;a sending unit, configured to: when the processing unit determines that the N to-be-read words are not cached in the cache device, forward the N read commands to a memory controller;
    所述接收单元,还用于接收所述内存控制器发送的所述N个待读字,以及The receiving unit is further configured to receive the N to-be-sent words sent by the memory controller, and
    所述发送单元,还用于向所述处理器发送所述N个待读字;The sending unit is further configured to send the N to-be-read words to the processor;
    所述接收单元,还用于接收所述内存控制器发送的所述N个待读字所属内存行中除所述N个待读字之外的其它字。The receiving unit is further configured to receive, in the memory row to which the N to-be-read words are sent by the memory controller, other words than the N to-be-read words.
  9. 根据权利要求8所述的缓存设备,其特征在于,所述接收单元用于接收所述内存控制器发送的第一字,包括:所述接收单元用于,接收所述内存控制器发送的所述第一字和所述第一字的优先级; The cache device according to claim 8, wherein the receiving unit is configured to receive the first word sent by the memory controller, and the receiving unit is configured to receive the location sent by the memory controller Describe the priority of the first word and the first word;
    所述处理单元,还用于根据所述第一字的优先级从高到低的顺序,缓存所述第一字;The processing unit is further configured to cache the first word according to a priority of the first word from high to low;
    其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The first word is a word other than the N to-be-read words in the memory lines to which the N to-be-read words or the N to-be-read words belong.
  10. 一种内存控制器,其特征在于,包括:A memory controller, comprising:
    接收单元,用于接收缓存设备发送的N个读命令,所述N为大于或等于2的整数,所述每个读命令包括待读字的地址,所述待读字的地址包括所述待读字所属内存行的地址以及所述待读字在所述内存行中的地址,所述读命令用于读取所述待读字;a receiving unit, configured to receive N read commands sent by the cache device, where N is an integer greater than or equal to 2, each read command includes an address of a word to be read, and the address of the word to be read includes the to-be-read Reading the address of the memory line to which the word belongs and the address of the word to be read in the memory line, the read command is used to read the word to be read;
    处理单元,用于根据所述N个待读字的地址,从所述N个待读字所属内存行中获取所述N个待读字;a processing unit, configured to acquire the N to-be-read words from the memory lines to which the N to-be-read words belong according to the addresses of the N to-be-read words;
    发送单元,用于向所述缓存设备发送所述N个待读字;a sending unit, configured to send the N to-be-read words to the cache device;
    所述处理单元,还用于从所述N个待读字所属内存行中获取除所述N个待读字之外的其它字;The processing unit is further configured to obtain, from the memory lines to which the N to-be-read words belong, words other than the N to-be-read words;
    所述发送单元,还用于向所述缓存设备发送所述其它字。The sending unit is further configured to send the other words to the cache device.
  11. 根据权利要求10所述的内存控制器,其特征在于,所述发送单元用于向所述缓存设备发送所述其它字,包括:所述发送单元用于根据所述N个待读字所属内存行中属于同一内存颗粒的除所述N个待读字之外的各个字的优先级从高至低的顺序,向所述缓存设备发送所述其它字。The memory controller according to claim 10, wherein the sending unit is configured to send the other words to the cache device, and the sending unit is configured to: according to the memory of the N to-be-read words The other words of the same memory particle belonging to the same memory particle in a descending order of priority of each of the N words to be read are sent to the cache device.
  12. 根据权利要求10或11所述的内存控制器,其特征在于,所述发送单元用于向所述缓存设备发送第一字,包括:所述发送单元用于,向所述缓存设备发送所述第一字和所述第一字的优先级;其中,所述第一字为所述N个待读字或者所述N个待读字所属内存行中除所述N个待读字之外的其它字。The memory controller according to claim 10 or 11, wherein the sending unit is configured to send the first word to the cache device, where the sending unit is configured to send the a first word and a priority of the first word; wherein the first word is the N to-be-read words or the N to-be-read words belong to a memory line other than the N to-be-read words Other words.
  13. 根据权利要求12所述的内存控制器,其特征在于,所述处理单元,还用于在所述发送单元向所述缓存设备发送所述第一字之前,根据所述N个待读字所属内存行中各个字的读写频率,确定所述各个字的优先级。The memory controller according to claim 12, wherein the processing unit is further configured to: before the sending unit sends the first word to the cache device, according to the N to-be-read words The frequency of reading and writing of each word in the memory line determines the priority of each word.
  14. 根据权利要求10-13任意一项所述的内存控制器,其特征在于,所述N个待读字所属内存行中的每个字存储在一个内存颗粒中。A memory controller according to any one of claims 10-13, wherein each of the memory lines to which the N words to be read belong is stored in a memory chip.
  15. 一种计算机设备,其特征在于,包括:如权利要求8或9所述的缓存设备、如权利要求10-14任意一项所述的内存控制器、处理器以及内存设备。 A computer device, comprising: the cache device according to claim 8 or 9, the memory controller, the processor and the memory device according to any one of claims 10-14.
PCT/CN2014/090649 2014-11-07 2014-11-07 Memory access method and apparatus, and computer device WO2016070431A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201480038252.1A CN105900060B (en) 2014-11-07 2014-11-07 Memory pool access method, device and computer equipment
PCT/CN2014/090649 WO2016070431A1 (en) 2014-11-07 2014-11-07 Memory access method and apparatus, and computer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/090649 WO2016070431A1 (en) 2014-11-07 2014-11-07 Memory access method and apparatus, and computer device

Publications (1)

Publication Number Publication Date
WO2016070431A1 true WO2016070431A1 (en) 2016-05-12

Family

ID=55908444

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/090649 WO2016070431A1 (en) 2014-11-07 2014-11-07 Memory access method and apparatus, and computer device

Country Status (2)

Country Link
CN (1) CN105900060B (en)
WO (1) WO2016070431A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536526A (en) * 2017-03-02 2018-09-14 腾讯科技(深圳)有限公司 A kind of method for managing resource and device based on programmable hardware

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092778A (en) * 2013-01-23 2013-05-08 浪潮(北京)电子信息产业有限公司 Cache mirroring method for memory system
US8677078B1 (en) * 2007-06-28 2014-03-18 Juniper Networks, Inc. Systems and methods for accessing wide registers
CN103873562A (en) * 2014-02-27 2014-06-18 车智互联(北京)科技有限公司 Cache method and cache system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6581151B2 (en) * 2001-07-18 2003-06-17 Ip-First, Llc Apparatus and method for speculatively forwarding storehit data based on physical page index compare
CN100426273C (en) * 2007-05-31 2008-10-15 威盛电子股份有限公司 Memorizer access device and its method
CN101377749B (en) * 2007-08-31 2010-06-02 华为技术有限公司 Method, programmable logic device, system and apparatus for checking memory data
CN102193776B (en) * 2010-03-10 2014-06-18 上海海尔集成电路有限公司 Method for processing skip instruction and microcontroller
CN104050092B (en) * 2013-03-15 2018-05-01 上海芯豪微电子有限公司 A kind of data buffering system and method
CN103810116B (en) * 2013-12-24 2017-06-20 苏州国芯科技有限公司 For the instruction storage device of embedded system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8677078B1 (en) * 2007-06-28 2014-03-18 Juniper Networks, Inc. Systems and methods for accessing wide registers
CN103092778A (en) * 2013-01-23 2013-05-08 浪潮(北京)电子信息产业有限公司 Cache mirroring method for memory system
CN103873562A (en) * 2014-02-27 2014-06-18 车智互联(北京)科技有限公司 Cache method and cache system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536526A (en) * 2017-03-02 2018-09-14 腾讯科技(深圳)有限公司 A kind of method for managing resource and device based on programmable hardware
CN108536526B (en) * 2017-03-02 2022-09-13 腾讯科技(深圳)有限公司 Resource management method and device based on programmable hardware

Also Published As

Publication number Publication date
CN105900060B (en) 2019-05-03
CN105900060A (en) 2016-08-24

Similar Documents

Publication Publication Date Title
CN110275841B (en) Access request processing method and device, computer equipment and storage medium
US9727471B2 (en) Method and apparatus for stream buffer management instructions
JP6599898B2 (en) Providing memory bandwidth compression using a compression memory controller (CMC) in a system with a central processing unit (CPU)
JP5688823B2 (en) Streaming translation in display pipes
JP6768928B2 (en) Methods and devices for compressing addresses
JP6859361B2 (en) Performing memory bandwidth compression using multiple Last Level Cache (LLC) lines in a central processing unit (CPU) -based system
CN106326140B (en) Data copying method, direct memory access controller and computer system
CN109219805B (en) Memory access method, related device, system and storage medium of multi-core system
US9135177B2 (en) Scheme to escalate requests with address conflicts
KR102106261B1 (en) Method of operating memory controller and methods for devices having same
US20150143045A1 (en) Cache control apparatus and method
US9063860B2 (en) Method and system for optimizing prefetching of cache memory lines
TW201714090A (en) Memory device, memory addressing method, and article comprising tangible storage medium
US20180189202A1 (en) System memory having point-to-point link that transports compressed traffic
US20170091092A1 (en) Coherent interconnect for managing snoop operation and data processing apparatus including the same
US8359433B2 (en) Method and system of handling non-aligned memory accesses
CN107250995B (en) Memory management device
KR101702374B1 (en) Multi processor device and inter process communication method thereof
US9904622B2 (en) Control method for non-volatile memory and associated computer system
US9990311B2 (en) Peripheral interface circuit
CN112639749A (en) Method, apparatus and system for reducing pipeline stalls due to address translation misses
US8661169B2 (en) Copying data to a cache using direct memory access
US20150261616A1 (en) Method of controlling memory swap operation and data processing system using same
WO2016070431A1 (en) Memory access method and apparatus, and computer device
US8719542B2 (en) Data transfer apparatus, data transfer method and processor

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: 14905501

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: 14905501

Country of ref document: EP

Kind code of ref document: A1