The embodiments discussed herein are related to an information processing apparatus, a cache memory controlling apparatus, and a memory access order assuring method.
The TSO (Total Store Ordering) is one type of memory ordering. The TSO has limitations for changing writing order in which data is actually written into a memory with respect to order of instructions which access the memory. There are three TSO rules:
In other words, the preceding store instruction can be passed to process the load instruction, but other passing patterns are inhibited. However, when a target data of the load instruction is included in a target data of the preceding store instruction, it is necessary for the load instruction to load the data of the preceding store instruction.
Here, in a processor which processes a memory access out of order, the preceding load instruction can be passed to process the subsequent load instruction, and the data can be returned before the processing of the preceding load instruction to an instruction control unit as follow.
Next, the instruction control unit 100 issues a load instruction load-B to the cache control unit 200. When a cache hit occurs on a target data of the load instruction load-B, the cache control unit 200 passes a processing of the preceding load instruction load-A, executes a processing of the subsequent load instruction load-B, and returns data-B, which is the target data of the load instruction load-B, to the instruction control unit 100.
After that, when receiving transferred data from the external storage means, the cache control unit 200 executes the processing of the load instruction load-A, and returns data-A, which is the target data of the load instruction load-A, to the instruction control unit 100.
As described above, in the out-of-order processing, data is not always read from a cache in order of the instructions. However, the instructions are actually executed by the instruction control unit 100 in order of the instructions. Thus, in a processor which supports only single thread, even when the data is read out of order, as long as the TSO between the load/store instructions is observed, it seems from software that the TSO is observed.
However, in an SMT (Simultaneous Multi Thread) processor, a plurality of threads which are simultaneously executed share a primary cache. Then, it becomes necessary to avoid a TSO infringement between the threads in single processor.
The SMT is technique for simultaneously executing the plurality of threads on a single CPU. In other words, the SMT processor is the processor provided with a function for simultaneously executing the plurality of threads. There is a Patent Document 1 which describes the prior art for the SMT processor. The Patent Document 1 describes that consistency of execution order is assured for the reading and the writing of shared data between the threads.
Patent Document 1: WO2004/068361
According to an aspect of the embodiment, an information processing apparatus includes an instruction control unit, a cache control unit, a processing unit, a determination circuit, and an instruction re-execution request circuit. The instruction control unit controls a plurality of threads, each of the plurality of threads being a sequence of instructions. The cache control unit includes a cache memory. The processing unit processes instructions out of order, and executing the plurality of threads simultaneously, and the instructions include store instructions and load instructions. The determination unit determines whether or not a second thread including a first load instruction and a second load instruction executes the second load instruction before the first load instruction and a target data of the second load instruction is returned to the instruction control unit before the store instruction is executed when a store instruction to the cache memory is executed by a first thread. The instruction re-execution request unit requests the instruction control unit to re-execute instructions from a next instruction of the first load instruction to the second load instruction at a time of processing the first load instruction when the determination unit determines that the target data of the second load instruction is returned to the instruction control unit before the store instruction is executed.
According to the embodiment, in the SMT processor which processes the memory access out of order, order of data update between the threads is assured.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention, as claimed.
Here, a following case is described. That is, there are an area A in which the data does not exist, and an area B in which the data exists, on the cache RAM 210. One thread (thread-α) in a processor issues instructions from the instruction control unit 100 to the primary cache control unit 200 in order of store-A and store-B for the area A and area B. And, another thread (thread-β) in the processor issues instructions from the instruction control unit 100 to the primary cache control unit 200 in order of load-B and load-A for the area B and the area A (refer to
The store-A and the store-B issued in the thread-α are held in a FP 220α in order of the store-A and the store-B. And, the load-B and the load-A issued in the thread-β are held in a FP 220β in order of the load-B and the load-A. In
In the primary cache control unit 200, it is assumed that the instruction issued in the thread-β is firstly processed. Then, the area B of the cache RAM 210 is accessed by the preceding load-B in the thread-β. But, data of the area B does not exist in the cache RAM 210, so that a cache miss occurs on the data. Thus, the data of the load-B is requested to a secondary cache control unit 300.
While the target data of the load-B is requested to the secondary cache control unit 300, the area A of the cache RAM 210 is accessed by the subsequent load-A. In this case, a cache hit occurs on the data, and obtained data-A (old) is returned to the instruction control unit 100. In
After that, as illustrated in
After that, the load-B of the thread-β is reprocessed in the primary cache control unit 200. When the area B of the cache RAM 210 is accessed by the load-B, a cache hit occurs on the data, and obtained data-B (new) is returned to the instruction control unit 100 (refer to
As a result, although the instructions are issued in order of the store-A and the store-B in the thread-α, in the thread-β, the stored data is returned in the processing of the load-B, and the pre-stored data is returned in the processing of the load-A. Thus, passing prohibition is infringed between the load instructions in the TSO.
An embodiment provides a technique to solve the above problem, and to assure in the SMT processor for processing a memory access out of order that the order of store processing executed in one thread is reflected to loading processes executed in another thread in the same processor.
To solve the above problem, an SMT processor for simultaneously executing a plurality of threads employs the following. When processing of a subsequent load instruction is executed in one thread before processing of a preceding load instruction and target data of the subsequent load instruction is returned before the processing of the preceding load instruction to an instruction control unit, the execution of storage processing for the target data by another thread may cause the TSO infringement. Therefore, when the preceding load instruction is processed, the instruction control unit is requested to re-execute instructions from next instruction of the preceding load instruction to the above subsequent load instruction, and then the TSO infringement is avoided.
In a cache control unit of the SMT processor for simultaneously executing a plurality of threads, each entry of an FP for each thread is provided with a flag indicating that processing is completed and a flag indicating that it is necessary to re-execute the instruction because of the storage processing in another thread, and each FP of each thread is provided with information indicating an entry which holds the oldest request.
When storage processing is executed in one thread α, an entry in another thread β is extracted which has a target address corresponds to a target address in the executed storage processing and holds a load type instruction whose processing is completed. And, when the entry is extracted, a flag is set indicating that re-execution of the instruction is needed due to the storage processing of another thread for all the entries from a first entry to a second entry. The first entry is an entry which holds the oldest request of the FP of the thread β, or the next entry. The second entry is an entry which has the target address corresponds to the target address in the executed storage processing and holds the processing-completed load type instruction.
When the oldest request of the FP of the thread β is executed, for an instruction held in the entry in which the flag is set indicating that re-execution of the instruction is needed due to the storage processing of another thread, the re-execution request of the instruction is issued to the instruction control unit.
Preferred embodiments of the present invention will be explained with reference to accompanying drawings.
The instruction control unit 10 issues a request such as a load instruction and a store instruction to the primary cache control unit 20. The primary cache control unit 20 executes processing in response to a request from the instruction control unit 10. When data which is a target of the request from the instruction control unit 10 does not exist in the cache RAM 21, the primary cache control unit 20 requests the secondary cache control unit 30 to transfer the corresponding data. When the request from the instruction control unit 10 is a load instruction, the primary cache control unit 20 returns the data to the instruction control unit 10.
The secondary cache control unit 30 receives the request of data transfer from the primary cache control unit 20, and then confirms whether the data requested from the primary cache control unit 20 exists in a cache RAM provided in the secondary cache control unit 30. When the requested data exists, the secondary cache control unit 30 returns the requested data to the primary cache control unit 20. When the data requested from the primary cache control unit 20 does not exist, the secondary cache control unit 30 requests external storage means to transfer the corresponding data.
In the primary cache control unit 20, the cache RAM 21 is storage means with a small capacity and a fast access.
The FP 22 includes a plurality of entries which hold the requests received from the instruction control unit 10. Each entry of the FP 22 is provided with a store-initiated instruction re-execution request flag (RIS: ReIfetch for Store). The instruction issued from the instruction control unit 10 is cyclically assigned to the plurality of entries of the FP 22 according to execution order of the instruction. The requests held in the FP 22 are read out of order, and target data of the read request which can be processed may be returned to the instruction control unit 10. The FP 22 is provided for each parallel-executed thread.
The FP-TOQ 23 is a register which holds information indicating an entry which holds the oldest request among the entries of the FP 22. The FP-TOQ 23 is provided for each parallel-executed thread like the FP 22.
A release timing of the request held in the FP 22 is a processing completion time of the request held in the entry indicated by the FP-TOQ 23. There is a case that processing of the request held in the entry, which is not indicated by the FP-TOQ 23, is completed before the processing of the preceding load instruction by passing processing of the request held in the entry indicated by the FP-TOQ 23. In this case, the request which is processed before the processing of the preceding load instruction is continued to be held in the FP 22 as being indicated to be in a completion status. After that, at the time point that the request held in the entry indicated by the FP-TOQ 23 is completed, the processing-completed entries are collectively released.
When the data on the cache RAM 21 is rewritten by the store instruction, the store control unit 24 notifies the address correspondence determination circuit 25 of a target address of the store instruction.
The address correspondence determination circuit 25 receives the target address of the store instruction from the store control unit 24, and searches the FP 22 of the thread other than the thread to which the store instruction belongs. As a result of the search, when the request is detected which is a load instruction, whose processing is completed, and whose target address corresponds to the received address, the address correspondence determination circuit 25 sets the store-initiated instruction re-execution request flag. This flag is set to all entries from an entry indicated by the FP-TOQ 23 or an entry next to the entry indicated by the FP-TOQ 23 to the entry which holds the detected request. The address correspondence determination circuit 25 may set the store-initiated instruction re-execution request flag to only an entry which holds the detected request.
When processing of the request held in the entry indicated by the FP-TOQ 23 is executed, the instruction re-execution request circuit 26 transfers the re-execution request of the instruction to the instruction control unit 10 for the request held in the entry in which the store-initiated instruction re-execution request flag is set.
In the present embodiment, it is assumed that the “valid” becomes “0” when the held request is invalid, and becomes “1” when the held request is valid. It is assumed that the “status” becomes “incomplete” when the processing of the held request is not completed, and becomes “complete” when the processing of the held request is completed. It is assumed that the store-initiated instruction re-execution request flag is “0” in the case of default, and becomes “1” in the case of flag set.
When an entry, in which the “valid” is “1”, the “status” is “complete”, and the “opcode” is the load type instruction, does not exist in the searched FP 22 (step S12 No), the store-initiated instruction re-execution request flag (RIS) is not set.
When the entry, in which the “valid” is “1”, the “status” is “complete”, and the “opcode” is the load type instruction, exists in the searched FP 22 (step S12 Yes), and when the “address” of the entry and the target address in the executed storage processing correspond to each other (step S13 Yes), the store-initiated instruction re-execution request flag (RIS) is set to all the entries from a next entry of the entry indicated by the FP-TOQ23 to the corresponding entry (step S14).
Even when the entry, in which the “valid” is “1”, the “status” is “complete”, and the “opcode” is the load type instruction, exists in the searched FP 22 (step S12 Yes), and when the “address” of the entry and the target address in the executed storage processing does not correspond to each other (step S13 No), the store-initiated instruction re-execution request flag (RIS) is not set.
The data is transferred to the instruction control unit 10 by the request held in the entry FP#n (step S20). Then, when the entry FP#n is the entry indicated by the FP-TOQ23 (step S21 Yes), and when the entry, in which the “valid” is “1”, and the instruction re-execution request flag (RIS) is “1”, exists in the FP 22 of the thread including the entry FP#n (step S22 Yes), the instruction control unit 10 is requested to re-execute the instruction for all the requests held in the corresponding entry (step S23).
In the examples illustrated in
It is assumed that, with regard to instructions issued from the instruction control unit 10 in the thread-α, the store-A is held in the 0-th entry (hereinafter, described as FPα#0) of FP22α, the store-B is held in the 1-th entry (hereinafter, described as FPα#1) of FP22α, and FP-TOQ23α of the FP22α indicates the entry FPα#0. It is assumed that, with regard to the instruction issued from the instruction control unit 10 in the thread-β, the load-B is held in the 0-th entry (hereinafter, described as FPβ#0) of FP22β, the load-A is held in the 1-th entry (hereinafter, described as FPβ#1) of FP22β, and FP-TOQ23β of the FP22β indicates the entry FPβ#0 (refer to
It is basically in random order that the request is first issued from which of the FP22α and the FP22β, and the request held in which entry is first processed in the FP22α and the FP22β. Here, it is assumed that the request held in the entry is processed in order of the FPβ#0, the FPβ#1, the FPα#0, and the FPα#1.
The primary cache control unit 20 firstly executes processing of the load-B held in the FPβ#0. However, data does not exist in the area B of the cache RAM 21, so that a cache miss occurs on the data. Then, the primary cache control unit 20 requests the secondary cache control unit 30 or a main memory (not-illustrated) to transfer the data (refer to
By the time that the requested data arrives at the cache RAM 21, the processing of the load-A held in the FPβ#1 is started, and a cache hit occurs on the data. Thus, the data of the area A of the cache RAM 21 is read, and the obtained data-A (old) is returned to the instruction control unit 10 (refer to
And, at this time point, the processing of the load-A held in the FPβ#1 is completed, but the processing of the load-B held in the FPβ#0 indicated by the FP-TOQ23β is not completed. Accordingly, at this time point, the flag of the processing completion is set to the FPβ#1, but the FPβ#1 is not released.
After that, the processing of the store-A held in the FPα#0 of the thread-α is executed, and the data is written in the area A of the cache RAM 21. When the data is written for this store-A, the addresses of all the processing-completed requests are checked which are held in the FP22 of the thread other than the thread-α. In this case, the addresses of the FP22β of the thread-β are checked. And, when an entry which holds the request of the address corresponding to the area A exists, the store-initiated instruction re-execution request flag (RIS) is set to all entries from an entry indicated by the FP-TOQ23β of the FP22β or an entry next to the entry indicated by the FP-TOQ23β of the FP22β to the corresponding entry. In this case, the entry FPβ#1 which holds the request of the address corresponding to the area-A exists, so that the store-initiated instruction re-execution request flag (RIS) is set to the entries from the FPβ#0 indicated by the FP-TOQ23β of the FP22β to the FPβ#1, or set to only the entry FPβ#1 (refer to
After that, the data including the area B arrives at the primary cache control unit 20 from the secondary cache control unit 30, and is written in the area B of the cache RAM 21. The processing of the store-B held in the FPα#1 of the thread-α is executed, and the data is written in the area B of the cache RAM 21 (refer to
After that, the re-processing of the load-B held in the FPβ#0 of the thread-β is executed, and a cache hit occurs on the data. Then, the data of the area B of the cache RAM 21 is read, and the obtained data-B (new) is returned to the instruction control unit 10. In this case, the FPβ#0 is the entry indicated by the FP-TOQ23β. Thus, for the entry in which the store-initiated instruction re-execution request flag (RIS) is set, the re-execution request of the instruction is issued to the instruction control unit 10 (refer to
The load-A is again requested as the thread-β from the instruction control unit 10, and the request is held in the second entry (hereinafter, described as FPβ#2) of the FP22β. Then, processing of the load-A held in the FPβ#2 is executed, and a cache hit occurs on the data. Thus, the data of the area A of the cache RAM 21 is read, and the obtain data-A (new) is returned to the instruction control unit 10 (refer to
In a case that the above mechanism for the store-initiated instruction re-execution does not employed, the state in which the data returned to the instruction control unit 10 in the processing of the load-B of the thread-β is the stored data but the data returned in the processing of the load-A is the pre-stored data. This state seems from software that the processing order of the store-A and the store-B of the thread-α is reversed, so that it results in the TSO infringement. Since the store-initiated instruction re-execution is executed, the stored data of the thread-α is returned in the processing of both the load-A and the load-B of the thread-β, so that the TSO infringement can be avoided.
The information processing apparatus, the cache memory controlling apparatus, and the memory access order assuring method are related to the technique used by the information processing apparatus, and particularly, to the technique used by a computer including a cache.
All examples and conditional language recited herein are intended for pedagogical purpose to aid the reader in understanding the invention and the concepts contributed by the inventor to furthering the art, and are to be construed as being without limitation to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although the embodiments of the present inventions have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
This is a continuation application of PCT application serial number PCT/JP2007/062389, filed on Jun. 20, 2007.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/JP2007/062389 | Jun 2007 | US |
Child | 12654380 | US |