WO2012127589A1 - マルチコアプロセッサシステム、および分岐予測方法 - Google Patents

マルチコアプロセッサシステム、および分岐予測方法 Download PDF

Info

Publication number
WO2012127589A1
WO2012127589A1 PCT/JP2011/056659 JP2011056659W WO2012127589A1 WO 2012127589 A1 WO2012127589 A1 WO 2012127589A1 JP 2011056659 W JP2011056659 W JP 2011056659W WO 2012127589 A1 WO2012127589 A1 WO 2012127589A1
Authority
WO
WIPO (PCT)
Prior art keywords
thread
branch prediction
cpu
branch
processor system
Prior art date
Application number
PCT/JP2011/056659
Other languages
English (en)
French (fr)
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 JP2013505649A priority Critical patent/JPWO2012127589A1/ja
Priority to PCT/JP2011/056659 priority patent/WO2012127589A1/ja
Publication of WO2012127589A1 publication Critical patent/WO2012127589A1/ja
Priority to US14/029,511 priority patent/US20140019738A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3804Instruction prefetching for branches, e.g. hedging, branch folding
    • G06F9/3806Instruction prefetching for branches, e.g. hedging, branch folding using address prediction, e.g. return stack, branch history buffer
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • G06F9/30058Conditional branch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3842Speculative instruction execution
    • G06F9/3844Speculative instruction execution using dynamic branch prediction, e.g. using branch history tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3851Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution from multiple instruction streams, e.g. multistreaming

Definitions

  • the present invention relates to a multi-core processor system and a branch prediction method for predicting the result of a branch instruction.
  • an increasing number of devices adopt a form of a multi-core processor system having a plurality of cores in one system.
  • application programs hereinafter referred to as “apps”
  • a thread is a unit of program execution.
  • a technique is disclosed in which the processing amount of threads is fined and fine-grain parallelism is used.
  • pipeline processing is disclosed in which the core is divided into stages such as fetch, interpretation, and execution executed by one instruction, and each stage is executed in a pipeline manner.
  • the core can improve the processing performance by simultaneously executing a plurality of instructions while shifting the stage.
  • the core cannot determine an instruction to be executed next when a branch instruction in which a subsequent instruction changes depending on a result of the preceding instruction is read. In this case, the core stops the pipeline and waits until the branch instruction is completed, so that the processing performance decreases.
  • a branch prediction technique for predicting the branch direction is disclosed in order to avoid a decrease in processing performance due to such a branch instruction.
  • branch prediction techniques can be broadly classified into static branch prediction and dynamic branch prediction.
  • Static branch prediction is a method in which a hint of a branch direction is described in a program, and the branch direction is predicted by referring to the hint at the time of execution.
  • Dynamic branch prediction stores the history of past branches, individual branch destinations, and branch frequency information (hereinafter referred to as branch prediction information) in the core memory, and refers to branch prediction information during execution to determine the branch direction. It is a method of predicting.
  • a technique for performing dynamic branch prediction for example, there is a technique for performing branch prediction using a past branch history for a specific branch instruction and a branch history corresponding to a branch instruction group executed before the present time. It is disclosed. Also, as a technique to improve the accuracy of dynamic branch prediction, for example, for multiple threads running on multiple cores, refer to the branch prediction information of another thread running on another core from each thread (For example, refer to Patent Documents 1 and 2 below).
  • the branch prediction information held in the dynamic branch prediction is held in the memory of the core. Since the memory capacity is finite, the core deletes old branch prediction information, branch prediction information with low reference frequency, etc. from the branch prediction information group, and overwrites with new branch prediction information. In addition, in the case of branch prediction information for a branch instruction that has not been executed more than a sufficient number of times in the past, dynamic branch prediction has poor prediction accuracy and lowers processing performance.
  • the dynamic prediction branch in the parallel processing with the fine-grain parallelism has a problem that the prediction accuracy of the branch prediction is deteriorated and the processing performance is deteriorated because the number of execution times of one branch instruction is reduced. Further, since the total number of types of dynamic prediction branches in parallel processing with fine-grain parallelism increases, instruction sequences having no correlation are executed one after another. Therefore, branch prediction information is overwritten one after another, and there is a problem that the prediction accuracy of branch prediction deteriorates.
  • An object of the present invention is to provide a multi-core processor system and a branch prediction method capable of improving the accuracy of branch prediction when executing a thread with fine granularity of parallel processing in order to solve the above-described problems caused by the prior art.
  • a plurality of CPUs, a plurality of branch prediction memories provided corresponding to each of the plurality of CPUs, and a plurality of CPUs are executed.
  • a branch corresponding to a first thread of the plurality of threads executed by the first CPU of the plurality of CPUs, and a shared branch prediction memory storing branch prediction information corresponding to each of the plurality of threads to be executed A multi-core processor system and a branch prediction method for setting prediction information from a shared branch prediction memory to a branch prediction memory corresponding to a first CPU are proposed.
  • FIG. 1 is an explanatory diagram of an operation of the multi-core processor system 100 according to the first embodiment.
  • FIG. 2 is a block diagram of hardware of the multi-core processor system 100 according to the first embodiment.
  • FIG. 3 is a block diagram showing functions of the multi-core processor system 100.
  • FIG. 4 is a block diagram showing software of the multi-core processor system 100.
  • FIG. 5 is an explanatory diagram showing an example of the contents stored in the independent branch prediction table 302.
  • FIG. 6 is an explanatory diagram showing an example of the contents stored in the shared branch prediction table 304.
  • FIG. 7 is an explanatory diagram showing a method for setting a thread type identifier.
  • FIG. 8 is a sequence diagram when the multi-core processor system 100 performs a normal operation.
  • FIG. 8 is a sequence diagram when the multi-core processor system 100 performs a normal operation.
  • FIG. 9 is a sequence diagram when the multi-core processor system 100 performs an interruption operation.
  • FIG. 10 is a flowchart showing thread activation processing.
  • FIG. 11 is a flowchart showing a thread operation end process.
  • FIG. 12 is a block diagram of hardware of the multi-core processor system 100 according to the second embodiment.
  • FIG. 13 is a block diagram of hardware of the multi-core processor system 100 according to the third embodiment.
  • FIG. 14 is a flowchart (part 1) illustrating a thread activation process according to the third embodiment.
  • FIG. 15 is a flowchart (part 2) illustrating the start of thread assignment according to the third embodiment.
  • FIG. 16 is a flowchart of a thread operation end process according to the third embodiment.
  • FIG. 17 is a block diagram of hardware of the multi-core processor system 100 according to the fourth embodiment.
  • FIG. 18 is an explanatory diagram of an example of the stored contents of the shared branch prediction table 1701 according to the fourth embodiment.
  • Embodiments 1 to 4 of the disclosed multi-core processor system, branch prediction method, and branch prediction program will be described in detail below with reference to the accompanying drawings.
  • FIG. 1 is an explanatory diagram of an operation of the multi-core processor system 100 according to the first embodiment.
  • the explanatory diagram denoted by reference numeral 101 shows an example of threads executed in the application 103.
  • An explanatory diagram denoted by reference numeral 102 indicates a state of branch prediction accuracy in a thread executed in the application 103.
  • Threads 1-0 to 1-4 are mutually correlated processes, and the thread type is referred to as thread 1 type.
  • the threads 2-0 to 2-1 are processes correlated with each other, and the thread type is referred to as thread 2 type. There is no correlation between threads belonging to the thread 1 type and threads belonging to the thread 2 type.
  • the application 103 issues an execution request for the thread 1-0.
  • the application 103 issues an execution request for the thread 1-1 and the thread 2-0 using the result of the thread 1-0.
  • the application 103 makes a determination using the result of the thread 1-1 and the result of the thread 2-0. If the determination result is Yes, the application 103 executes the thread 1-2 and the thread 2-1. Note that the thread 2-1 uses the result of the thread 1-1 and does not use the result of the thread 2-0. Therefore, the thread 2-1 can execute speculation without waiting for the determination at the end of the thread 1-1.
  • the application 103 issues an execution request for the thread 1-3 using the result of the thread 1-2 and the result of the thread 2-1, and the thread 1-3 is terminated. Thereafter, an execution request for the thread 1-4 that uses the result of the thread 1-3 is issued.
  • the application 103 issues an execution request for the thread 2-0 'and issues an execution request for the thread 1-4 that uses the result of the thread 2-0'.
  • the application 103 does not use the result of the thread 2-1.
  • the multi-core processor system 100 includes CPU # 0 to CPU # 2, and further includes thread 1 type branch prediction information 104 and thread 2 type branch prediction information 105. At time t0, the storage contents of the thread 1 type branch prediction information 104 and the storage contents of the thread 2 type branch prediction information 105 are initial values.
  • CPU # 1 and CPU # 2 include a branch prediction table 106 # 1 and a branch prediction table 106 # 2 that store branch prediction information.
  • the CPU # 0 When the activation start of the thread 1-0 is received at time t0, the CPU # 0 reads the thread 1 type branch prediction information 104 and stores it in the branch prediction table 106 # 1 of the CPU # 1 that executes the thread 1-0. Write. From time t0 to time t1, the CPU # 1 executes the thread 1-0 belonging to the thread 1 type, and stores the branch result of the branch instruction serving as the branch prediction information in the branch prediction table 106 # 1. When the thread 1-0 is completed at time t1 and the operation ends, the CPU # 1 writes the branch prediction information stored in the branch prediction table 106 # 1 into the thread 1 type branch prediction information 104.
  • the CPU # 0 reads the thread 1 type branch prediction information 104 and writes it in the branch prediction table 106. Similarly, when starting activation of a thread belonging to the thread 2 type, the CPU # 0 reads the thread 2 type branch prediction information 105 and writes it in the branch prediction table 106.
  • time t0 to the time t1 are assumed to be short, and the amount of stored branch prediction information is small.
  • CPU # 1 executes a branch instruction about 1/3 of the number of times that the branch prediction accuracy is improved. Therefore, the accuracy of branch prediction accompanying thread 1-0 execution at time t1 is poor.
  • the CPU # 0 reads the branch prediction information 104 for the thread 1 type, and the branch prediction table 106 of the CPU # 1 that executes the thread 1-1. Write to # 1.
  • the CPU # 0 reads the thread 2-type branch prediction information 105 and writes it in the branch prediction table 106 # 1 of the CPU # 1 that executes the thread 2-0.
  • branch prediction information of thread 1 is accumulated in the branch prediction table 106 # 1
  • branch prediction information of thread 2 is accumulated in the branch prediction table 106 # 2.
  • the branch prediction table 106 # 1 also includes branch prediction information accumulated between time t0 and time t1, and as a whole, it is accumulated about 2/3 of the number of times that the branch prediction accuracy is improved. The accuracy of branch prediction is moderate. Further, the branch prediction table 106 # 2 stores about 1/3 of the number of times that the branch prediction accuracy is improved as the branch prediction information accumulated between the time t1 and the time t2. bad.
  • CPU # 1 speculatively executes thread 2-1.
  • the CPU # 0 makes a determination using the results of the thread 1-1 and the thread 2-0.
  • the CPU # 0 since the determination result is No, the CPU # 0 does not need the result of the thread 2-1, and therefore interrupts the speculative execution of the thread 2-1.
  • the thread 2-1 is a thread that is not originally executed when the speculative execution is not performed, and the branch prediction information accumulated by the speculative execution has other adverse effects. Therefore, the CPU # 0 discards the branch prediction information accumulated by the thread 2-1.
  • branch prediction information of thread 2 is accumulated in the branch prediction table 106 # 1, and branch prediction information of thread 1 is accumulated in the branch prediction table 106 # 2.
  • the branch prediction table 106 # 1 also includes branch prediction information accumulated between time t1 and time t2, and as a whole, the branch prediction information is accumulated about 2/3 times the number of times that the branch prediction accuracy is improved. As a result, the accuracy of branch prediction is moderate.
  • the branch prediction table 106 # 2 stores the branch prediction information for the number of times that the branch prediction accuracy is improved together with the already stored branch prediction information, so that the accuracy of the branch prediction is improved.
  • the CPU # 0 reads the thread 1 type branch prediction information 104 into the branch prediction table 106 # 1 and the branch prediction table 106 # 2. Since the branch prediction information for the thread 1 type at time t4 is sufficiently stored, the CPU # 1 and the CPU # 2 can execute the threads 1-3 and 1-4 at high speed. it can.
  • the multi-core processor system 100 has a history of branch prediction results for each thread, sets a corresponding history each time the core executes a thread, and collects it after completion. As a result, the multi-core processor system 100 can accumulate the history even for threads that have a small granularity and end immediately, and can improve the prediction accuracy.
  • hardware and software of the multi-core processor system 100 for realizing the operation shown in FIG. 1 will be described.
  • FIG. 2 is a block diagram of hardware of the multi-core processor system 100 according to the first embodiment.
  • the multi-core processor system 100 includes CPUs 201 on which a plurality of CPUs are mounted, a ROM (Read-Only Memory) 202, and a RAM (Random Access Memory) 203.
  • the multi-core processor system 100 includes a flash ROM 204, a flash ROM controller 205, and a flash ROM 206.
  • the multi-core processor system 100 includes a display 207, an I / F (Interface) 208, and a keyboard 209 as input / output devices for a user and other devices. Each unit is connected by a bus 210.
  • the CPUs 201 control the entire multi-core processor system 100.
  • the CPUs 201 indicates all CPUs in which single core processors are connected in parallel.
  • the CPUs 201 include CPU # 0 to CPU # 2.
  • the CPUs 201 may include at least two CPUs.
  • CPU # 0 to CPU # 2 each have a dedicated cache memory.
  • a multi-core processor system is a computer system including a processor having a plurality of cores. If a plurality of cores are mounted, a single processor having a plurality of cores may be used, or a processor group in which single core processors are arranged in parallel may be used. In the present embodiment, an example in which CPUs that are single-core processors are arranged in parallel will be described.
  • the CPU # 0 to CPU # 2 can access the shared branch prediction register 212 through the branch prediction information bus 211.
  • the shared branch prediction register 212 stores branch prediction information that is shared and used by the CPUs # 0 to # 2.
  • the ROM 202 stores programs such as a boot program.
  • the RAM 203 is used as a work area for the CPUs 201.
  • the flash ROM 204 is a flash ROM having a high reading speed, and is, for example, a NOR flash memory.
  • the flash ROM 204 stores system software such as an OS (Operating System), application software, and the like. For example, when updating the OS, the multi-core processor system 100 receives the new OS by the I / F 208 and updates the old OS stored in the flash ROM 204 to the received new OS.
  • OS Operating System
  • the flash ROM controller 205 controls reading / writing of data with respect to the flash ROM 206 according to the control of the CPUs 201.
  • the flash ROM 206 is a flash ROM mainly for storing and transporting data, and is, for example, a NAND flash memory.
  • the flash ROM 206 stores data written under the control of the flash ROM controller 205.
  • data image data, video data, etc. acquired by the user using the multi-core processor system 100 through the I / F 208, a program for executing the branch prediction method according to the present embodiment, and the like may be stored. Good.
  • As the flash ROM 206 for example, a memory card, an SD card, or the like can be adopted.
  • the display 207 displays data such as a document, an image, and function information as well as a cursor, an icon, or a tool box.
  • a TFT liquid crystal display can be adopted as the display 207.
  • the I / F 208 is connected to a network 213 such as a LAN (Local Area Network), a WAN (Wide Area Network), or the Internet through a communication line, and is connected to another device via the network 213.
  • the I / F 208 controls an internal interface with the network 213 and controls input / output of data from an external device.
  • a modem or a LAN adapter can be adopted as the I / F 208.
  • the keyboard 209 has keys for inputting numbers and various instructions, and inputs data.
  • the keyboard 209 may be a touch panel type input pad or a numeric keypad.
  • FIG. 3 is a block diagram showing functions of the multi-core processor system 100.
  • Multicore processor system 100 includes a detection unit 311, a reading unit 312, a writing unit 313, a reading unit 314, and a writing unit 315.
  • the functions (detection unit 311 to writing unit 315) serving as the control unit are realized by the CPUs 201 executing the program stored in the storage device.
  • the storage device is, for example, the ROM 202, RAM 203, flash ROM 204, flash ROM 206, etc. shown in FIG.
  • the detection unit 311 to the writing unit 315 are illustrated as functions of the CPU # 0 serving as the master CPU, but may be functions of the CPU # 1 or the CPU # 2.
  • the multi-core processor system 100 can access the main memory 301, the independent branch prediction table 302, and the shared branch prediction table 304.
  • the CPUs # 0 to # 2 access through the independent branch prediction table I / F 303.
  • the CPU # 0 executes the main thread 305.
  • the CPU # 1 executes the sub thread 306.
  • the main memory 301 is a main storage device accessible from the CPUs 201.
  • the main memory 301 may be the entire RAM 203 or a part of the RAM 203.
  • the independent branch prediction table 302 stores branch prediction information accessed by a dynamic branch prediction mechanism.
  • the dynamic branch prediction mechanism include a Bi-modal method, a G-Share method, a perceptron branch prediction method, and a method combining the above-described methods. Details of the independent branch prediction table 302 will be described later with reference to FIG.
  • the independent branch prediction table 302 is provided in each of the CPUs # 0 to # 2, and is stored in each register.
  • the independent branch prediction table I / F 303 is an I / F that enables reading and writing to branch prediction information in the independent branch prediction table 302 of each CPU from outside the CPU.
  • the shared branch prediction table 304 is a table that stores branch prediction information for each thread type. Details of the shared branch prediction table 304 will be described later with reference to FIG.
  • the detecting unit 311 has a function of detecting that the first thread among the plurality of threads is executed by the first CPU among the plurality of CPUs. Further, the detection unit 311 may detect that the operation of the first thread has ended. For example, the detection unit 311 detects that the sub thread 306 is executed by the CPU # 1. Information that the target thread is executed is stored in the register of CPU # 0, the cache memory, the main memory 301, and the like.
  • the reading unit 312 has a function of reading the branch prediction information corresponding to the first thread detected by the detection unit 311 from a memory that stores a branch prediction history shared by the CPUs. For example, the reading unit 312 reads the branch prediction information corresponding to the sub thread 306 from the shared branch prediction table 304.
  • the reading unit 312 clears and clears the area where the branch prediction information is not stored.
  • the area may be read as branch prediction information corresponding to the first thread.
  • the read branch prediction information is stored in a register of CPU # 0, a cache memory, or the like.
  • the writing unit 313 has a function of writing the branch prediction information read by the reading unit 312 into a memory that stores a branch prediction history corresponding to the first CPU. For example, the writing unit 313 writes the branch prediction information in the independent branch prediction table 302 # 1 of the CPU # 1.
  • the information that the writing has been performed may be stored in the register of CPU # 0, the cache memory, the main memory 301, or the like.
  • the reading unit 314 has a function of reading branch prediction information in a memory that stores a branch prediction history corresponding to the first CPU when the operation of the first thread is completed. For example, the reading unit 314 reads the branch prediction information in the independent branch prediction table 302 # 1 of the CPU # 1 when the execution of the sub thread 306 is completed.
  • the read branch prediction information is stored in a register of CPU # 0, a cache memory, or the like.
  • the writing unit 315 has a function of writing the branch prediction information read by the reading unit 312 into a memory that stores a branch prediction history shared by the CPUs. For example, the writing unit 315 writes the read branch prediction information in the shared branch prediction table 304.
  • the information that the writing has been performed may be stored in the register of CPU # 0, the cache memory, the main memory 301, or the like.
  • FIG. 4 is a block diagram showing software of the multi-core processor system 100.
  • the multi-core processor system 100 in FIG. 4 executes a thread control library (master) 401, a thread control library (slave) 402 # 1, and a thread control library (slave) 402 # 2. Furthermore, the multi-core processor system 100 executes the branch prediction control library 403.
  • the multi-core processor system 100 executes the main thread 305 and the thread A1, the thread A2, the thread B1, the thread B2, the thread C1, the thread C2, the thread D1, and the thread D2 that are executed according to the request of the main thread 305.
  • Thread A1 and thread A2 belong to the same thread type as thread A.
  • thread B1 and thread B2 belong to the same thread type called thread B
  • thread C1 and thread C2 belong to the same thread type called thread C
  • thread D1 and thread D2 are the same thread called thread D. It belongs to the type.
  • the CPU # 0 executes the thread control library (master) 401, the branch prediction control library 403, and the main thread 305.
  • the CPU # 1 executes the threads A1 to D2 in accordance with the thread activation request made by the main thread 305 via the thread control library (master) 401 and the thread control library (slave) 402 # 1.
  • the CPU # 2 executes the threads A1 to D2 in accordance with the thread activation request made via the thread control library (master) 401 and the thread control library (slave) 402 # 2.
  • the multi-core processor system 100 takes the form of AMP (Asymmetric MultiProcessing), which is often employed in an embedded system, and assigns a specific thread to a CPU core. Further, the multi-core processor system 100 may take the form of SMP (Symmetric MultiProcessing) in which the position of the CPU is equal.
  • AMP Asymmetric MultiProcessing
  • SMP Symmetric MultiProcessing
  • the thread control library (master) 401 and the thread control library (slave) 402 have a function of executing a thread after scheduling based on a thread activation request from the main thread 305.
  • the thread control library (master) 401 notifies the thread control library (slave) 402 to execute the thread A1 after performing scheduling based on the thread activation request from the main thread 305.
  • the thread control library (slave) 402 that has received the notification causes the CPU # 1 to execute the thread A1.
  • the thread control library (master) 401 and the thread control library (slave) 402 have a function of notifying the main thread 305 of the completion of the thread operation when the thread operation is completed.
  • the thread control library (slave) 402 notifies the thread control library (master) 401 when the operation of the thread A1 is completed.
  • the thread control library (master) 401 that has received the notification notifies the main thread 305 that the operation of the thread has ended.
  • the branch prediction control library 403 has a function of accessing the shared branch prediction table 304 and transferring branch prediction information at the timing of starting the thread of the thread control library (master) 401 and ending the thread operation of the thread control library (slave) 402. Have For example, when the thread A1 is activated, the branch prediction control library 403 accesses the shared branch prediction table 304 and transfers the branch prediction table information corresponding to the thread A to the CPU # 1.
  • FIG. 5 is an explanatory diagram showing an example of the contents stored in the independent branch prediction table 302.
  • the independent branch prediction table 302 includes a GHR (Global History Register) 501, a PHT (Pattern History Table) 502, and a BTB (Branch Target Buffer) 503.
  • the independent branch prediction table 302 includes a BTB update circuit 504, a GHR update circuit 505, a PHT update circuit 506, an entry selection unit 507, an address matching unit 508, and a prediction direction determination unit as circuits and function units that operate the GHR 501 to BTB 503. 509.
  • the independent branch prediction table I / F 303 updates GHR 501 to BTB 503 serving as branch prediction information.
  • the GHR 501 is a register that stores whether branch instructions for the past several times have been established or not established.
  • the identifier indicating when the branch instruction is established is “T” indicating establishment or “N” indicating failure.
  • the GHR 501 stores established, established, not established, and established as the results of establishment of the last four branch instructions.
  • the PHT 502 is a table that expresses whether a branch instruction tends to be established or not established by a saturation counter of several bits. Possible values of the PHT 502 are “2′b00” indicating that the possibility of not branching is large, “2′b01” indicating that the possibility of not branching is small, and “2 ′” indicating that the possibility of branching is small. “b10” is “2′b11” indicating that the possibility of branching is high. “2′b” indicates a binary number.
  • the BTB 503 is a buffer that stores a branch destination address for each branch instruction.
  • the BTB 503 includes three fields: a valid flag, a branch source instruction address, and a branch destination instruction address.
  • the valid flag field stores a value indicating whether or not the corresponding record is valid. For example, if the valid flag field is “1”, this indicates that the corresponding record is valid. If the valid flag field is “0”, it indicates that the corresponding record is invalid.
  • the branch source instruction address field stores an address that becomes a branch instruction. In the branch destination instruction address field, a branch destination address for branching is stored.
  • the BTB update circuit 504 is a circuit that updates the BTB 503 based on the branch source instruction address and the branch destination instruction address. Specifically, the BTB update circuit 504 selects a record of the BTB 503 using the lower bits of the branch source instruction address, and sets a valid flag, a branch source instruction address, and a branch destination instruction address.
  • the GHR update circuit 505 is a circuit that updates the GHR 501 based on the branch destination direction. Specifically, the GHR update circuit 505 receives 1 [bit] information indicating the establishment or non-establishment of the branch instruction from the branch destination direction, and sets the information in the GHR 501.
  • the PHT update circuit 506 is a circuit that updates the PHT 502 based on the branch source instruction address and the branch destination direction. Specifically, the PHT update circuit 506 selects the PHT 502 record using the lower bits of the branch source instruction address, and changes the counter in the PHT 502. More specifically, the PHT update circuit 506 increments the counter if the branch destination direction is information indicating that the branch is established, and decrements the counter if the branch destination direction is information indicating that the branch is not established.
  • the entry selection unit 507 has a function of selecting a record of the PHT 502 based on the lower bits of the prediction target address and the GHR 501. For example, the entry selection unit 507 combines the bit string of the GHR 501 with the lower bits of the prediction target address, and generates data that can uniquely select the PHT 502 record. Further, the entry selection unit 507 may calculate the XOR between the lower bits of the prediction target address and the bit string of the GHR 501 as data that can uniquely select the record of the PHT 502.
  • the address matching unit 508 determines whether or not the upper bits of the prediction target address match the branch source instruction address. If they match, the address matching unit 508 outputs a signal indicating that the addresses match.
  • the prediction direction determination unit 509 has a function of determining whether or not the branch instruction corresponding to the prediction target address branches. Specifically, the prediction direction determination unit 509 receives a signal that the addresses match from the address matching unit 508, and the branch is established when the record selected by the entry selection unit 507 may branch. Output the branch destination direction.
  • the independent branch prediction table 302 when a prediction target address is input to the independent branch prediction table 302, the independent branch prediction table 302 outputs, as an output, whether or not a branch is established as a branch destination direction. Is output.
  • FIG. 6 is an explanatory diagram showing an example of the contents stored in the shared branch prediction table 304.
  • the shared branch prediction table 304 includes two fields: tag information and branch prediction table information.
  • the tag information field further includes two fields: a valid flag and a thread type identifier.
  • the valid flag field stores a value indicating whether or not the corresponding branch prediction information is valid. For example, if the valid flag field is “1”, this indicates that the branch prediction information is valid.
  • the thread type identifier field stores information for identifying the thread type.
  • information for identifying the thread type for example, the head address of the instruction sequence may be set as the thread type as information that can uniquely identify the thread.
  • a common identifier may be set for each correlated thread. A specific method for setting the thread type identifier will be described later with reference to FIG.
  • the branch prediction table information is information including three fields: a GHR field corresponding to the GHR 501 shown in FIG. 5, a PHT field corresponding to the PHT 502, and a BTB field corresponding to the BTB 503.
  • the contents stored in each field of the branch prediction table information are equal to GHR 501 to BTB 503 described in FIG.
  • the tag information for one thread and the branch prediction table information are collectively referred to as one entry of the shared branch prediction table 304.
  • the shared branch prediction table 304 shown in FIG. 6 a total of four entries of entries 601 to 604 are registered.
  • the thread type identifier is thread A
  • the branch prediction table information all branches are established in the GHR field, and two records “2′b10” and “2′b11” are registered in the PHT field.
  • two records are registered in the BTB field. The details of the two records are a record including a branch source instruction address “0x00001000” and a branch destination instruction address “0x2000C400”, a record including a branch source instruction address “0x00001CC0” and a branch destination instruction address “0xC0F00000”.
  • the thread type identifier is thread B
  • branch prediction table information includes branch establishment, branch failure, branch failure, branch failure, and PHT field “2′b00” and “2′b11” as branch prediction table information. 2 records are registered. Further, in the entry 602, one record is registered in the BTB field. The details of one record are records composed of a branch source instruction address “0x00001CC0” and a branch destination instruction address “0xFD010000”.
  • the thread type identifier is thread C.
  • the branch failure is established in the GHR field, the branch is established, the branch is not established, the branch is not established, and the PHT field is “2′b10”, “2′b11”. 2 records are registered. Further, in the entry 603, two records are registered in the BTB field. The details of the two records are a record including a branch source instruction address “0x00001000” and a branch destination instruction address “0x2000C000”, and a record including a branch source instruction address “0x00001CC0” and a branch destination instruction address “0x40000300”.
  • the thread type identifier is thread D.
  • all branches are established in the GHR field, and two records “2′b00” and “2′b01” are registered in the PHT field. . Note that there is no valid record in the BTB field of the entry 604.
  • FIG. 7 is an explanatory diagram showing a thread type identifier setting method.
  • FIG. 7 illustrates a method for setting a thread type identifier when the multi-core processor system 100 performs image processing.
  • the multi-core processor system 100 is assumed to perform specific processing on the image 701.
  • the specific process may be any process such as color correction or hue / saturation conversion.
  • the multi-core processor system 100 performs processing by dividing the image 701 into areas 1 to 4.
  • the CPU # 0 executes the thread belonging to the thread A type, the thread belonging to the thread B type, and the thread belonging to the thread C type to the area 1 in this order.
  • the threads to be executed are the thread A1, the thread B1, and the thread C1, respectively.
  • CPU # 1 executes for the area 2
  • CPU # 2 executes for the area 3 in order of thread A1, thread B1, and thread C1.
  • the thread type identifier of the specific entry is set to the thread A type, the specific entry is accessed by a thread group belonging to the group 702. If the thread type identifier of a specific entry is set to an identifier indicating the area 1, the specific entry is accessed by a thread group belonging to the group 703.
  • the identifier indicating the area 1 is the head address of the area 1, a file pointer on the file system, or the like.
  • the thread type identifier of a specific entry is set to an identifier indicating the area 2
  • the specific entry is accessed by a thread group belonging to the group 704.
  • the thread type identifier of a specific entry is set to an identifier indicating the area 3
  • the specific entry is accessed by a thread group belonging to the group 705.
  • the multi-core processor system 100 can improve the prediction accuracy.
  • FIG. 8 is a sequence diagram when the multi-core processor system 100 performs normal operation.
  • the CPU # 0 executes the main thread 305, the thread control library (master) 401, and the branch prediction control library 403. Further, the CPU # 1 accesses the independent branch prediction table 302 # 1, and executes the thread control library (slave) 402 and the thread 1.
  • the main thread 305 notifies the thread control library (master) 401 of a thread activation request (step S801).
  • the thread control library (master) 401 that has received the notification further notifies the branch prediction control library 403 of a thread activation preparation request (step S802).
  • the branch prediction control library 403 that has received the thread activation preparation request reads the branch prediction information from the shared branch prediction table 304 by using the thread type identifier for which the activation request has been made (step S803). After the completion of reading (step S804), the branch prediction control library 403 writes the read branch prediction information in the independent branch prediction table 302 # 1 (step S805). After the completion of writing (step S806), the branch prediction control library 403 notifies the thread control library (master) 401 of completion of thread activation preparation (step S807).
  • the thread control library (master) 401 that has received the completion of thread activation preparation notifies the thread activation request to the thread control library (slave) 402 # 1 (step S808), and notifies the main thread 305 of the completion of thread activation (step S809). ).
  • the thread control library (slave) 402 that has received the thread activation request activates the thread 1 by the CPU # 1 (step S810). During execution of thread 1, CPU # 1 accesses independent branch prediction table 302 # 1 and performs branch prediction.
  • the thread control library (slave) 402 receives the end of the thread operation (step S811), and notifies the thread control library (master) 401 of the end of the thread operation (step S812).
  • the thread control library (master) 401 that has received the end of the thread operation notifies the main thread of the end of the thread operation (step S813) and notifies the branch prediction control library 403 of the end of the thread operation (step S814).
  • the branch prediction control library 403 that has received the notification reads the branch prediction information from the independent branch prediction table 302 # 1 (step S815).
  • the branch prediction control library 403 writes the read branch prediction information in the shared branch prediction table 304 after the completion of reading (step S816) (step S817).
  • the branch prediction control library 403 notifies the thread control library (master) 401 of completion of the thread operation after the completion of writing (step S818) (step S819).
  • FIG. 9 is a sequence diagram when the multi-core processor system 100 performs an interruption operation.
  • the sequence shown in steps S901 to S910 is the same as the sequence shown in steps S801 to S810, and thus the description thereof is omitted.
  • the main thread 305 notifies the thread control library (master) 401 of a thread interruption request (step S911).
  • the thread control library (master) 401 that has received the notification notifies the thread control library (slave) 402 # 1 of a thread suspension request (step S912), and notifies the main thread 305 of a thread suspension response (step S913).
  • the thread control library (slave) 402 # 1 that has received the thread interruption request interrupts the thread 1 (step S914) and notifies the thread control library (master) 401 of the end of the thread interruption (step S915).
  • the thread control library (master) 401 that has received the end of thread interruption notifies the thread operation interruption notification (step S916).
  • the branch prediction control library 403 that has received the thread operation interruption notification notifies the thread control library (master) 401 of the completion of the thread operation interruption without updating the shared branch prediction table 304 (step S917).
  • the thread control library (master) 401 that has received the completion of the thread operation interruption notifies the main thread 305 of the completion of the thread operation interruption (step S918).
  • FIGS. 10 and 11 show a flowchart of the thread operation end process. Note that the thread operation termination process occurs when the thread process is completed or the thread process is interrupted and terminated.
  • FIG. 10 is a flowchart showing a thread activation process.
  • CPU # 0 acquires the thread type identifier of the thread to be activated (step S1001). After acquisition, the CPU # 0 accesses the shared branch prediction table 304 using the thread type identifier (step S1002).
  • CPU # 0 determines whether valid branch prediction information exists as a result of the access (step S1003). When valid branch prediction information exists (step S1003: Yes), the CPU # 0 reads the branch prediction information from the shared branch prediction table 304 (step S1004).
  • step S1003 If there is no valid branch prediction information (step S1003: No), the CPU # 0 searches for an empty entry in the shared branch prediction table 304 (step S1005). The empty entry is an entry whose valid flag is “0”. After the search, CPU # 0 determines whether there is an empty entry (step S1006). If there is an empty entry (step S1006: Yes), the CPU # 0 clears the empty entry, sets and validates the acquired thread type identifier (step S1007), and reads the cleared branch prediction information (step S1007). S1008).
  • step S1006 When there is no empty entry (step S1006: No), or after the end of steps S1004 and S1008, the CPU # 0 determines the CPU that executes the thread (step S1009).
  • the CPU that executes the thread is determined by the function of the scheduler of the OS or the like.
  • CPU # 0 determines whether or not the branch prediction information has been read (step S1010).
  • the CPU # 0 writes the branch prediction information in the independent branch prediction table 302 of the CPU that executes the thread (step S1011).
  • the CPU # 0 requests the CPU executing the thread to execute the thread (step S1012), and ends the thread activation process.
  • the thread activation process also occurs for the thread after switching when switching to another thread by the scheduling function of the OS.
  • the CPU # 0 executes the process of step S1001 as “acquires the thread type identifier of the thread after switching”.
  • the thread activation process may be performed on the thread after switching in thread switching that occurs when the time slice assigned to the thread expires.
  • the thread activation process may be performed on the returned thread after being interrupted by an ISR (Interrupt Service Route).
  • FIG. 11 is a flowchart showing thread operation end processing.
  • CPU # 0 receives an operation end notification from the CPU that executed the thread (step S1101). After receiving the notification, the CPU # 0 determines whether or not the thread is interrupted and terminated (step S1102). When the thread ends without being interrupted (step S1102: No), the CPU # 0 reads the branch prediction information from the independent branch prediction table 302 of the CPU that executed the thread (step S1103). After reading, CPU # 0 obtains the thread type identifier of the terminated thread (step S1104).
  • CPU # 0 accesses the shared branch prediction table 304 using the thread type identifier (step S1105). As a result of the access, the CPU # 0 determines whether there is valid branch prediction information (step S1106). When valid branch prediction information exists (step S1106: Yes), the CPU # 0 overwrites the branch prediction information in the shared branch prediction table 304 with the branch prediction information in the independent branch prediction table 302 (step S1107). If there is no valid branch prediction information after overwriting (step S1106: No), or if the thread is interrupted and terminated (step S1102: Yes), the CPU # 0 executes processing for cleaning up the thread ( Step S1108). After execution, CPU # 0 ends the thread operation end processing.
  • the thread operation end processing also occurs for a thread before switching when switching to another thread by the scheduling function of the OS.
  • the CPU # 0 executes the process of step S1101 as “notification of thread switching from the CPU executing the thread”, and executes the process of step S1104 as “obtains the thread type identifier of the thread before switching”. To do. Further, CPU # 0 does not execute the process of step S1108.
  • each thread has a branch prediction result history
  • the corresponding history is stored as the branch prediction history in the core.
  • the multi-core processor system may discard the branch prediction history accumulated by the thread that executed the speculative execution when the thread that executed the speculative execution is interrupted. As a result, the multi-core processor system does not have to mix the branch prediction history by the thread that has not been executed into the currently accumulated branch prediction result history, and accumulates a more accurate branch prediction result history. be able to.
  • the multi-core processor system may have a bus for transferring the branch prediction information from a memory storing a branch prediction history shared by the CPUs to a memory storing a branch prediction history in each CPU. Good. Thereby, the multi-core processor system can transfer the branch prediction information without being disturbed by the transfer of other data.
  • the multi-core processor system clears the area in which the branch prediction information is not stored. You may read as corresponding branch prediction information. As a result, the multi-core processor system can effectively use the free space.
  • the multi-core processor system can maintain the accuracy of branch prediction even if the thread granularity is fine. For example, assume that a specific core executes a fine-grained thread and the other cores execute a fine-grained thread. In the prior art, since the other cores cannot refer to the branch prediction information of the fine-grained thread executed in the specific core, the prediction accuracy has deteriorated. In the first embodiment, other cores can refer to branch prediction information of fine-grained threads executed by a specific core, and can improve prediction accuracy.
  • the multi-core processor system uses the memory for branch prediction information held by the core in the prior art.
  • the same branch prediction accuracy as that obtained by N times can be realized. Since the memory used for the shared branch prediction table is accessed less frequently than the memory for branch prediction information held by the core, a low-speed memory can be used, and the cost can be reduced.
  • FIG. 12 is a block diagram of hardware of the multi-core processor system 100 according to the second embodiment.
  • the storage location of the shared branch prediction table 304 is different from the hardware of the multicore processor system 100 in the first embodiment.
  • the multi-core processor system 100 according to the second embodiment has the same hardware and the same functions as the multi-core processor system 100 according to the first embodiment except for the storage location of the shared branch prediction table 304. Is omitted.
  • the shared branch prediction table 304 is stored in the main memory 301.
  • the independent branch prediction table 302 is mapped to the I / O space and is accessible from each CPU.
  • the branch prediction information bus 211 and the bus 210 are connected by an independent branch prediction table I / F 303 # B.
  • the CPU # 0 accesses the shared branch prediction table 304 via the independent branch prediction table I / F 303 # 0 and the independent branch prediction table I / F 303 # B.
  • the branch prediction control library 403 reads the branch prediction information of the thread to be activated from the shared branch prediction table 304 on the main memory 301 when the thread is activated. Subsequently, the branch prediction control library 403 writes the shared branch prediction table 304 in the independent branch prediction table 302 of the CPU that executes the thread on the I / O space. Thereby, compared with the multi-core processor system 100 according to the first embodiment, the additional hardware cost can be reduced. Further, the multi-core processor system 100 according to the second embodiment does not have to add a storage element for storing the shared branch prediction table 304 when the main memory 301 has a free space.
  • FIG. 13 is a block diagram of hardware of the multi-core processor system 100 according to the third embodiment.
  • the storage location of the shared branch prediction table 304 is the main memory 301, and a part thereof is stored in the shared branch prediction register 212 as the shared branch prediction table cache 1301. .
  • the shared branch prediction table cache 1301 has the same fields as the shared branch prediction table 304.
  • the multi-core processor system 100 according to the third embodiment has the same hardware and the same functions as the multi-core processor system 100 according to the first embodiment except for the storage location of the shared branch prediction table 304. Is omitted.
  • FIG. 14 is a flowchart (part 1) illustrating a thread activation process according to the third embodiment.
  • steps S1406 to S1411 are the same as steps S1003 to S1008 shown in FIG. 10 except for the processing after step S1409: No. To do.
  • CPU # 0 acquires the thread type identifier of the thread to be activated (step S1401). After acquisition, the CPU # 0 accesses the shared branch prediction table cache 1301 using the thread type identifier (step S1402). CPU # 0 determines whether valid branch prediction information exists as a result of the access (step S1403). When valid branch prediction information exists (step S1403: Yes), the CPU # 0 reads the branch prediction information from the shared branch prediction table cache 1301 (step S1404). After reading, CPU # 0 proceeds to the process of step S1503.
  • step S1403 If there is no valid branch prediction information (step S1403: No), the CPU # 0 accesses the shared branch prediction table 304 of the main memory 301 using the thread type identifier (step S1405). After step S1407 or step S1411, the CPU # 0 proceeds to the process of step S1501. Further, after the process of step S1409: No, the CPU # 0 proceeds to the process of step S1503.
  • FIG. 15 is a flowchart (part 2) illustrating the start of thread assignment according to the third embodiment. Steps S1503 to S1506 are the same as steps S1009 to S1012 shown in FIG.
  • the CPU # 0 selects one entry in the shared branch prediction table cache 1301 using the replacement algorithm (step S1501).
  • the replacement algorithm may be, for example, LRU (Least Recently Used), LFU (Least Frequently Used), or the like.
  • the CPU # 0 overwrites the selected entry in the shared branch prediction table 304 of the main memory 301 (step S1502).
  • FIG. 16 is a flowchart of thread operation end processing according to the third embodiment.
  • steps S1601 to S1604 are the same as steps S1101 to S1104 shown in FIG.
  • the processing from step S1609 to step S1611 is the same as that from step S1106 to step S1108, and a description thereof will be omitted.
  • CPU # 0 accesses the shared branch prediction table cache 1301 using the thread type identifier (step S1605). After access, CPU # 0 determines whether valid branch prediction information exists (step S1606). When valid branch prediction information exists (step S1606: Yes), the CPU # 0 overwrites the branch prediction information in the shared branch prediction table cache 1301 with the branch prediction information in the independent branch prediction table 302 (step S1607), and step The processing shifts to S1611.
  • step S1606 When there is no valid branch prediction information (step S1606: No), the CPU # 0 accesses the shared branch prediction table 304 of the main memory 301 using the thread type identifier (step S1608). After access, CPU # 0 proceeds to the process of step S1609.
  • the multi-core processor system 100 can reduce the performance overhead associated with thread activation and thread operation termination when there is temporal locality in thread activation.
  • the branch prediction information is acquired based on the currently executed thread type.
  • the multi-core processor system 100 according to the fourth embodiment acquires branch prediction information based on the past thread activation history.
  • FIG. 17 is a block diagram of hardware of the multi-core processor system 100 according to the fourth embodiment.
  • the multi-core processor system 100 according to the fourth embodiment includes a shared branch prediction table 1701 instead of the shared branch prediction table 304 according to the first embodiment. Details of the shared branch prediction table 1701 will be described later with reference to FIG.
  • the multicore processor system 100 according to the fourth embodiment is the same as the multicore processor system 100 according to the first embodiment except for the shared branch prediction table 304, and has the same functions except for the reading unit 312. Therefore, the description is omitted.
  • the reading unit 312 stores the branch prediction history shared by each CPU with branch prediction information corresponding to the first thread detected by the detection unit 311 and the second thread executed before the first thread. Read from memory.
  • FIG. 18 is an explanatory diagram of an example of the storage contents of the shared branch prediction table 1701 according to the fourth embodiment.
  • the shared branch prediction table 1701 includes a thread activation order identifier field instead of the thread type identifier of the shared branch prediction table 304.
  • the other fields in the shared branch prediction table 1701 store the same stored contents as the other fields in the shared branch prediction table 304, and thus description thereof is omitted.
  • the thread activation order identifier field stores thread type identifier groups in the order in which threads are activated. For example, in the thread activation order identifier field of entry 1801, the thread type identifier to be activated this time is thread A, the thread of type B is activated before that, and the thread of type C is activated before that. It is shown that. Hereinafter, to simplify the description, it is assumed that the threads executed in each thread type are a thread A1, a thread B1, a thread C1, and a thread D1, respectively. Similarly, the thread activation order identifier field of the entry 1802 indicates that the thread activated this time is the thread B1, the thread B1 is activated before that, and the thread A1 is activated before that.
  • the thread activation order identifier field of the entry 1803 indicates that the thread activated this time is the thread C1, the thread B1 is activated before that, and the thread A1 is activated before that.
  • the thread activation order identifier field of the entry 1804 indicates that the thread activated this time is the thread C1, the thread B1 is activated before that, and the thread D1 is activated before that.
  • the multi-core processor system 100 accesses the shared branch prediction table 1701 and executes thread start processing and operation end processing.
  • a specific flowchart can be dealt with by replacing the thread type identifier with the thread activation sequence identifier in the flowcharts shown in FIGS.
  • branch prediction information is set based on the activation order of threads.
  • the multi-core processor system can improve the branch prediction accuracy when there is a correlation between the thread activation order and the tendency of individual branches.
  • branch prediction method described in the first to fourth embodiments can be realized by executing a program prepared in advance on a computer such as a personal computer or a workstation.
  • a program for executing this branch prediction method is recorded on a computer-readable recording medium such as a hard disk, a flexible disk, a CD-ROM, an MO, and a DVD, and is executed by being read from the recording medium by the computer.
  • the program for executing this branch prediction method may be distributed via a network such as the Internet.
  • Multi-core processor system 208 I / F 210 Bus 211 Branch prediction information bus 212 Branch prediction information register 301 Main memory 302 Independent branch prediction table 303 Independent branch prediction table I / F 304 shared branch prediction table 305 main thread 306 sub thread 311 detecting unit 312 reading unit 313 writing unit 314 reading unit 315 writing unit

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Advance Control (AREA)
  • Debugging And Monitoring (AREA)

Abstract

 並列処理の粒度が細かいスレッドを実行する際に、分岐予測の精度を向上する。CPU(#0)は、時刻(t0)にて、並列処理の粒度が細かいスレッド(1-0)をCPU(#1)で実行する際に、スレッド1種別用分岐予測情報(104)を読み出し、分岐予測テーブル(106#1)に書き込む。スレッド(1-0)の動作終了後、CPU(#0)は、分岐予測テーブル(106#1)に蓄積された分岐予測情報をスレッド1種別用分岐予測情報(104)に書き込む。CPU(#0)は、上記動作を時刻(t1)、時刻(t3)でも行い、スレッド1種別用の分岐予測情報を蓄積し、分岐予測の精度を向上させる。

Description

マルチコアプロセッサシステム、および分岐予測方法
 本発明は、分岐命令の結果を予測するマルチコアプロセッサシステム、および分岐予測方法に関する。
 従来から、1つのシステム内に、複数のコアを有するマルチコアプロセッサシステムの形態を採用する機器が増加している。また、複数のコアを利用して、アプリケーションプログラム(以下、「アプリ」と称す)を複数のスレッドに分割し、スレッド単位での並列を行うことで、マルチコアプロセッサシステムは、単一のコアで処理を実行する場合より高速処理を可能にしている。なお、スレッドとはプログラムの実行単位である。また、スレッド単位の並列処理の性能をより高める方法として、スレッドの処理量を細かくし、細粒度並列性を用いるといった技術も開示されている。
 また、コアの高速化技術について、コアが1命令で実行するフェッチ、解釈、実行といったステージに分割し、パイプライン式で各ステージを実行するパイプライン処理が開示されている。パイプライン処理により、コアは、複数の命令を、ステージをずらして同時に実行することで処理性能を向上することができる。
 しかし、パイプライン処理で命令を実行するケースにおいて、コアは、先行する命令の結果によって後続する命令が変化する分岐命令を読み込むと、次に実行すべき命令が判断できない。この場合、コアは、パイプラインを停止し、分岐命令が完了するまで待機することになり、処理性能が低下する。
 このような分岐命令による処理性能の低下を避けるため、分岐方向を予測する分岐予測技術が開示されている。分岐予測技術を適用し、分岐命令が完了する前に次に実行すべき命令を予測することで、予測が正しかった場合に処理性能の低下を避けることができる。分岐予測技術は、静的分岐予測と動的分岐予測とに大別できる。静的分岐予測は、プログラム内に分岐方向のヒントを記載し、実行時にヒントを参照して分岐方向を予測する方法である。動的分岐予測とは、コアのメモリに過去の分岐の履歴や個々の分岐先、分岐頻度の情報(以下、分岐予測情報と称する)を保持し、実行時に分岐予測情報を参照して分岐方向を予測する方法である。
 たとえば、動的分岐予測を行う技術として、たとえば、特定の分岐命令に対する過去の分岐履歴と、現時点より前に実行された分岐命令群に対応する分岐履歴とを用いて、分岐予測を行う技術が開示されている。また、動的分岐予測の精度を向上させる技術として、たとえば、複数のコアで実行されている複数のスレッドに対して、各スレッドから他のコアで実行されている別スレッドの分岐予測情報を参照する技術が開示されている(たとえば、下記特許文献1、2を参照。)。
特開平9-244891号公報 特開2006-53830号公報
 しかしながら、上述した従来技術において、動的分岐予測にて保持される分岐予測情報は、コアの持つメモリに保持される。メモリの容量は有限であるため、コアは、分岐予測情報群のうち、古い分岐予測情報や、参照頻度の低い分岐予測情報等から削除し、新しい分岐予測情報で上書きする。また、動的分岐予測は、過去に充分な回数以上実行されていない分岐命令に対する分岐予測情報では、予測精度が悪く、処理性能が低下する。
 したがって、各コアが細粒度並列性での並列処理を行うと、スレッドあたりの処理ステップ数が小さくなり、同一の処理、または相関性のある処理を実行するスレッドを1種別とみなした場合の総種類数は増加する。このように、細粒度並列性で並列処理における動的予測分岐は、1つの分岐命令の実行回数が少なくなるため、分岐予測の予測精度が悪化し、処理性能が低下するという問題があった。また、細粒度並列性で並列処理における動的予測分岐は、総種類数が増加するため、相関性のない命令列が次々に実行される。したがって、分岐予測情報が次々に上書きされることになり、分岐予測の予測精度が悪化するという問題があった。
 本発明は、上述した従来技術による問題点を解消するため、並列処理の粒度が細かいスレッドを実行する際に、分岐予測の精度を向上できるマルチコアプロセッサシステム、および分岐予測方法を提供することを目的とする。
 上述した課題を解決し、目的を達成するため、本発明の一側面によれば、複数のCPUと、複数のCPUのそれぞれに対応して設けられる複数の分岐予測メモリと、複数のCPUで実行される複数のスレッドのそれぞれに対応する分岐予測情報を格納する共有分岐予測メモリと、を含み、複数のCPUの内の第1CPUによって実行される複数のスレッドの内の第1スレッドに対応する分岐予測情報を共有分岐予測メモリから第1CPUに対応する分岐予測メモリに設定するマルチコアプロセッサシステム、および分岐予測方法が提案される。
 本発明の一側面によれば、並列処理の粒度が細かいスレッドを実行する際に、分岐予測の精度を向上できるという効果を奏する。
図1は、実施の形態1にかかるマルチコアプロセッサシステム100の動作を示す説明図である。 図2は、実施の形態1にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。 図3は、マルチコアプロセッサシステム100の機能を示すブロック図である。 図4は、マルチコアプロセッサシステム100のソフトウェアを示すブロック図である。 図5は、独立分岐予測テーブル302の記憶内容の一例を示す説明図である。 図6は、共有分岐予測テーブル304の記憶内容の一例を示す説明図である。 図7は、スレッド種別識別子の設定方法を示す説明図である。 図8は、マルチコアプロセッサシステム100が正常動作を行う場合のシーケンス図である。 図9は、マルチコアプロセッサシステム100が中断動作を行う場合のシーケンス図である。 図10は、スレッドの起動処理を示すフローチャートである。 図11は、スレッドの動作終了処理を示すフローチャートである。 図12は、実施の形態2にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。 図13は、実施の形態3にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。 図14は、実施の形態3にかかるスレッドの起動処理を示すフローチャート(その1)である。 図15は、実施の形態3にかかるスレッドの割り当て開始を示すフローチャート(その2)である。 図16は、実施の形態3にかかるスレッドの動作終了処理を示すフローチャートである。 図17は、実施の形態4にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。 図18は、実施の形態4にかかる共有分岐予測テーブル1701の記憶内容の一例を示す説明図である。
 以下に添付図面を参照して、開示のマルチコアプロセッサシステム、分岐予測方法、および分岐予測プログラムの実施の形態1~4を詳細に説明する。
(実施の形態1の説明)
 図1は、実施の形態1にかかるマルチコアプロセッサシステム100の動作を示す説明図である。符号101で示す説明図は、アプリ103内にて実行されるスレッドの例を示している。符号102で示す説明図は、アプリ103内にて実行されるスレッドにおける分岐予測精度の状態を示している。
 アプリ103は、スレッド1-0、スレッド1-1、スレッド1-2、スレッド1-3、スレッド1-4、スレッド2-0、スレッド2-0’、スレッド2-1を実行する。スレッド1-0~スレッド1-4はお互いに相関性のある処理であり、スレッド種別をスレッド1種別と呼称する。同様に、スレッド2-0~スレッド2-1はお互いに相関性のある処理であり、スレッド種別をスレッド2種別と呼称する。スレッド1種別に属するスレッドとスレッド2種別に属するスレッドに関しては、相関性がない。
 また、スレッドの処理順序としては、アプリ103はスレッド1-0の実行要求を発行する。次に、アプリ103は、スレッド1-0の結果を利用するスレッド1-1、スレッド2-0の実行要求を発行する。続けて、アプリ103は、スレッド1-1の結果とスレッド2-0の結果を用いて判定を行う。判定結果がYesであれば、アプリ103は、スレッド1-2と、スレッド2-1を実行する。なお、スレッド2-1は、スレッド1-1の結果を利用し、スレッド2-0の結果を利用しない。したがって、スレッド2-1は、スレッド1-1終了時点で判定を待たずに投機実行可能である。
 スレッド1-2とスレッド2-1の終了後、アプリ103は、スレッド1-2の結果とスレッド2-1の結果を利用するスレッド1-3の実行要求を発行し、スレッド1-3の終了後、スレッド1-3の結果を利用するスレッド1-4の実行要求を発行する。
 また、判定結果がNoであれば、アプリ103は、スレッド2-0’の実行要求を発行し、スレッド2-0’の結果を利用するスレッド1-4の実行要求を発行する。なお、判定結果がNoである場合、アプリ103は、スレッド2-1の結果を利用しない。
 次に、符号102で示す説明図では、アプリ103内にて実行されるスレッドにおける分岐予測精度の状態を示している。マルチコアプロセッサシステム100は、CPU#0~CPU#2を含み、さらにスレッド1種別用分岐予測情報104と、スレッド2種別用分岐予測情報105と、を含む。また、時刻t0の時点では、スレッド1種別用分岐予測情報104の記憶内容とスレッド2種別用分岐予測情報105の記憶内容は、初期値である。また、CPU#1、CPU#2は、分岐予測情報を格納する分岐予測テーブル106#1、分岐予測テーブル106#2を含む。
 時刻t0にて、スレッド1-0の起動開始を受けると、CPU#0は、スレッド1種別用分岐予測情報104を読み出し、スレッド1-0を実行するCPU#1の分岐予測テーブル106#1に書き込む。時刻t0~時刻t1にて、CPU#1は、スレッド1種別に属するスレッド1-0を実行し、分岐予測情報となる分岐命令の分岐結果を分岐予測テーブル106#1に蓄積していく。時刻t1にてスレッド1-0が完了し、動作終了すると、CPU#1は、スレッド1種別用分岐予測情報104に分岐予測テーブル106#1に蓄積された分岐予測情報を書き込む。
 以降、スレッド1種別に属するスレッドを起動開始する場合、CPU#0は、スレッド1種別用分岐予測情報104を読み出して、分岐予測テーブル106に書き込む。同様に、スレッド2種別に属するスレッドを起動開始する場合、CPU#0は、スレッド2種別用分岐予測情報105を読み出して、分岐予測テーブル106に書き込む。
 なお、時刻t0~時刻t1は短い時間を想定しており、蓄積された分岐予測情報量は少ない。図1の例では、CPU#1が、分岐予測精度が良くなる回数の1/3程分岐命令を実行した場合を想定している。したがって、時刻t1でのスレッド1-0実行に伴う分岐予測の精度は悪い。
 次に、時刻t1にて、スレッド1-1の起動開始を受けると、CPU#0は、スレッド1種別用分岐予測情報104を読み出し、スレッド1-1を実行するCPU#1の分岐予測テーブル106#1に書き込む。同様に、スレッド2-0の起動開始を受けると、CPU#0は、スレッド2種別用分岐予測情報105を読み出し、スレッド2-0を実行するCPU#1の分岐予測テーブル106#1に書き込む。
 時刻t1~時刻t2にて、分岐予測テーブル106#1にはスレッド1の分岐予測情報が蓄積され、分岐予測テーブル106#2にはスレッド2の分岐予測情報が蓄積される。分岐予測テーブル106#1には、時刻t0~時刻t1間で蓄積された分岐予測情報も含まれており、全体として、分岐予測精度が良くなる回数の2/3程蓄積されることになり、分岐予測の精度が中程度となる。また、分岐予測テーブル106#2には、時刻t1~時刻t2間で蓄積された分岐予測情報として、分岐予測精度が良くなる回数の1/3程蓄積されることになり、分岐予測の精度は悪い。
 時刻t2にて、CPU#1は、スレッド2-1を投機実行する。また、CPU#0は、スレッド1-1、スレッド2-0の結果を用いて判定を行う。符号102で示す図では、判定結果がNoとなったので、CPU#0は、スレッド2-1の結果が不要となるため、スレッド2-1の投機実行を中断する。スレッド2-1は投機実行を行わない場合、本来実行されないスレッドであり、投機実行により蓄積された分岐予測情報は、他に悪影響を与える。したがって、CPU#0は、スレッド2-1により蓄積された分岐予測情報を破棄する。
 時刻t3~時刻t4にて、分岐予測テーブル106#1にはスレッド2の分岐予測情報が蓄積され、分岐予測テーブル106#2にはスレッド1の分岐予測情報が蓄積される。分岐予測テーブル106#1には、時刻t1~時刻t2間で蓄積された分岐予測情報も含まれており、全体として、分岐予測精度が良くなる回数の2/3程分岐予測情報が蓄積されることになり、分岐予測の精度が中程度となる。また、分岐予測テーブル106#2には、既に蓄積された分岐予測情報と併せて、分岐予測精度が良くなる回数分、分岐予測情報が蓄積されることになり、分岐予測の精度は良くなる。
 時刻t4にて、CPU#0は、分岐予測テーブル106#1、分岐予測テーブル106#2に、スレッド1種別用分岐予測情報104を読み出す。時刻t4におけるスレッド1種別用分岐予測情報104は、充分に分岐予測情報が蓄積されているため、CPU#1とCPU#2は、スレッド1-3とスレッド1-4を高速に実行することができる。
 このように、本実施の形態1にかかるマルチコアプロセッサシステム100は、スレッドごとに分岐予測結果の履歴を持ち、コアがスレッドを実行する度に、対応する履歴を設定し、終了後回収する。これにより、マルチコアプロセッサシステム100は、粒度が小さくすぐ終了してしまうスレッドでも履歴を蓄積でき、予測精度を向上することができる。以下、図1で示した動作を実現するためのマルチコアプロセッサシステム100のハードウェア、ソフトウェアの説明を行う。
(マルチコアプロセッサシステム100のハードウェア)
 図2は、実施の形態1にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。図2において、マルチコアプロセッサシステム100は、CPUを複数搭載するCPUs201と、ROM(Read‐Only Memory)202と、RAM(Random Access Memory)203と、を含む。また、マルチコアプロセッサシステム100は、フラッシュROM204と、フラッシュROMコントローラ205と、フラッシュROM206と、を含む。また、マルチコアプロセッサシステム100は、ユーザやその他の機器との入出力装置として、ディスプレイ207と、I/F(Interface)208と、キーボード209と、を含む。また、各部はバス210によってそれぞれ接続されている。
 ここで、CPUs201は、マルチコアプロセッサシステム100の全体の制御を司る。CPUs201は、シングルコアのプロセッサを並列して接続した全てのCPUを指している。CPUs201は、CPU#0~CPU#2を含む。また、CPUs201は、少なくとも2つ以上のCPUを含んでいてもよい。CPU#0~CPU#2は、それぞれ専用のキャッシュメモリを有する。また、マルチコアプロセッサシステムとは、コアが複数搭載されたプロセッサを含むコンピュータのシステムである。コアが複数搭載されていれば、複数のコアが搭載された単一のプロセッサでもよく、シングルコアのプロセッサが並列されているプロセッサ群でもよい。なお、本実施の形態では、シングルコアのプロセッサであるCPUが並列されている形態を例にあげて説明する。
 また、CPU#0~CPU#2は、分岐予測情報バス211を通じて、共有分岐予測レジスタ212にアクセス可能である。共有分岐予測レジスタ212は、CPU#0~CPU#2が共有して利用する分岐予測情報が格納されている。
 ROM202は、ブートプログラムなどのプログラムを記憶している。RAM203は、CPUs201のワークエリアとして使用される。フラッシュROM204は、読出し速度が高速なフラッシュROMであり、たとえば、NOR型フラッシュメモリである。フラッシュROM204は、OS(Operating System)などのシステムソフトウェアやアプリケーションソフトウェアなどを記憶している。たとえば、OSを更新する場合、マルチコアプロセッサシステム100は、I/F208によって新しいOSを受信し、フラッシュROM204に格納されている古いOSを、受信した新しいOSに更新する。
 フラッシュROMコントローラ205は、CPUs201の制御にしたがってフラッシュROM206に対するデータのリード/ライトを制御する。フラッシュROM206は、データの保存、運搬を主に目的としたフラッシュROMであり、たとえば、NAND型フラッシュメモリである。フラッシュROM206は、フラッシュROMコントローラ205の制御で書き込まれたデータを記憶する。データの具体例としては、マルチコアプロセッサシステム100を使用するユーザがI/F208を通して取得した画像データ、映像データなどや、また本実施の形態にかかる分岐予測方法を実行するプログラムなどを記憶してもよい。フラッシュROM206は、たとえば、メモリカード、SDカードなどを採用することができる。
 ディスプレイ207は、カーソル、アイコンあるいはツールボックスをはじめ、文書、画像、機能情報などのデータを表示する。ディスプレイ207は、たとえば、TFT液晶ディスプレイなどを採用することができる。
 I/F208は、通信回線を通じてLAN(Local Area Network)、WAN(Wide Area Network)、インターネットなどのネットワーク213に接続され、ネットワーク213を介して他の装置に接続される。そして、I/F208は、ネットワーク213と内部のインターフェースを司り、外部装置からのデータの入出力を制御する。I/F208には、たとえばモデムやLANアダプタなどを採用することができる。
 キーボード209は、数字、各種指示などの入力のためのキーを有し、データの入力を行う。また、キーボード209は、タッチパネル式の入力パッドやテンキーなどであってもよい。
(マルチコアプロセッサシステム100の機能)
 次に、マルチコアプロセッサシステム100の機能について説明する。図3は、マルチコアプロセッサシステム100の機能を示すブロック図である。マルチコアプロセッサシステム100は、検出部311と、読出部312と、書込部313と、読出部314と、書込部315と、を含む。この制御部となる機能(検出部311~書込部315)は、記憶装置に記憶されたプログラムをCPUs201が実行することにより、その機能を実現する。記憶装置とは、たとえば、図2に示したROM202、RAM203、フラッシュROM204、フラッシュROM206などである。なお、図3では、検出部311~書込部315は、マスタCPUとなるCPU#0の機能として図示されているが、CPU#1、またはCPU#2の機能であってもよい。
 また、マルチコアプロセッサシステム100は、メインメモリ301、独立分岐予測テーブル302、共有分岐予測テーブル304にアクセス可能である。CPU#0~CPU#2は、他CPUの独立分岐予測テーブル302にアクセスする際には、独立分岐予測テーブルI/F303を介してアクセスする。また、図3では、CPU#0がメインスレッド305を実行する。また、メインスレッド305の実行要求によって、CPU#1がサブスレッド306を実行する。
 メインメモリ301は、CPUs201からアクセス可能な主記憶装置である。たとえば、メインメモリ301は、RAM203全体であったり、RAM203の一部であったりしてもよい。
 独立分岐予測テーブル302は、動的な分岐予測機構でアクセスされる分岐予測情報を記憶する。動的な分岐予測機構としては、たとえば、Bi-Modal方式、G-Share方式、パーセプトロン分岐予測方式、または前述の方式を組み合わせた方式などである。独立分岐予測テーブル302の詳細は、図5にて後述する。また、独立分岐予測テーブル302は、CPU#0~CPU#2がそれぞれ有し、それぞれのレジスタに記憶されている。
 独立分岐予測テーブルI/F303は、CPUの外部から、各CPUが有する独立分岐予測テーブル302中の分岐予測情報に対して、読み込み可能、書き込み可能にするI/Fである。共有分岐予測テーブル304は、スレッド種類ごとに分岐予測情報を格納するテーブルである。共有分岐予測テーブル304の詳細は、図6にて後述する。
 検出部311は、複数のスレッドのうち第1スレッドを複数のCPUのうち第1CPUで実行されることを検出する機能を有する。また、検出部311は、第1スレッドが動作終了することを検出してもよい。たとえば、検出部311は、サブスレッド306がCPU#1で実行されることを検出する。なお、対象のスレッドが実行されるという情報は、CPU#0のレジスタ、キャッシュメモリ、メインメモリ301等に記憶される。
 読出部312は、検出部311によって検出された第1スレッドに対応する分岐予測情報を各CPUで共有された分岐予測の履歴を記憶するメモリから読み出す機能を有する。たとえば、読出部312は、サブスレッド306に対応する分岐予測情報を共有分岐予測テーブル304から読み出す。
 また、読出部312は、各CPUで共有された分岐予測の履歴を記憶するメモリに第1スレッドに対応する分岐予測情報がない場合、分岐予測情報が記憶されていない領域をクリアし、クリアした領域を第1スレッドに対応する分岐予測情報として読み出してもよい。なお、読み出された分岐予測情報は、CPU#0のレジスタ、キャッシュメモリ等に記憶される。
 書込部313は、読出部312によって読み出された分岐予測情報を第1CPUに対応する分岐予測の履歴を記憶するメモリに書き込む機能を有する。たとえば、書込部313は、CPU#1の独立分岐予測テーブル302#1に分岐予測情報を書き込む。なお、書き込みが行われたという情報は、CPU#0のレジスタ、キャッシュメモリ、メインメモリ301等に記憶されてもよい。
 読出部314は、第1スレッドの動作終了時、第1CPUに対応する分岐予測の履歴を記憶するメモリ内の分岐予測情報を読み出す機能を有する。たとえば、読出部314は、サブスレッド306の実行終了時、CPU#1の独立分岐予測テーブル302#1内の分岐予測情報を読み出す。なお、読み出された分岐予測情報は、CPU#0のレジスタ、キャッシュメモリ等に記憶される。
 書込部315は、読出部312によって読み出された分岐予測情報を各CPUで共有された分岐予測の履歴を記憶するメモリに書き込む機能を有する。たとえば、書込部315は、読み出された分岐予測情報を、共有分岐予測テーブル304に書き込む。なお、書き込みが行われたという情報は、CPU#0のレジスタ、キャッシュメモリ、メインメモリ301等に記憶されてもよい。
 図4は、マルチコアプロセッサシステム100のソフトウェアを示すブロック図である。図4におけるマルチコアプロセッサシステム100は、スレッド制御ライブラリ(マスタ)401とスレッド制御ライブラリ(スレイブ)402#1とスレッド制御ライブラリ(スレイブ)402#2とを実行する。さらに、マルチコアプロセッサシステム100は、分岐予測制御ライブラリ403を実行する。
 また、マルチコアプロセッサシステム100は、メインスレッド305と、メインスレッド305の要求によって実行されるスレッドA1、スレッドA2、スレッドB1、スレッドB2、スレッドC1、スレッドC2、スレッドD1、スレッドD2を実行する。なお、スレッドA1とスレッドA2は、スレッドAという同一のスレッド種別に属する。同様に、スレッドB1とスレッドB2は、スレッドBという同一のスレッド種別に属し、スレッドC1とスレッドC2は、スレッドCという同一のスレッド種別に属し、スレッドD1とスレッドD2は、スレッドDという同一のスレッド種別に属する。
 また、CPU#0は、スレッド制御ライブラリ(マスタ)401と、分岐予測制御ライブラリ403と、メインスレッド305と、を実行する。CPU#1は、メインスレッド305がスレッド制御ライブラリ(マスタ)401、スレッド制御ライブラリ(スレイブ)402#1を介して行ったスレッド起動要求にしたがって、スレッドA1~スレッドD2を実行する。CPU#2も同様に、スレッド制御ライブラリ(マスタ)401、スレッド制御ライブラリ(スレイブ)402#2を介して行ったスレッド起動要求にしたがって、スレッドA1~スレッドD2を実行する。
 このように、マルチコアプロセッサシステム100は、組み込みシステムでよく採用される、CPUコアに特定のスレッドを割り当てるAMP(Asymmetric MultiProcessing)の形態をとっている。また、マルチコアプロセッサシステム100は、CPUの立場が対等なSMP(Symmetric MultiProcessing)の形態をとってもよい。
 スレッド制御ライブラリ(マスタ)401とスレッド制御ライブラリ(スレイブ)402は、メインスレッド305からのスレッド起動要求に基づいて、スケジューリングを行ったうえでスレッドを実行させる機能を有する。たとえば、スレッド制御ライブラリ(マスタ)401は、メインスレッド305からのスレッド起動要求に基づいて、スケジューリングを行ったうえでスレッドA1を実行させるように、スレッド制御ライブラリ(スレイブ)402に通知する。通知を受けたスレッド制御ライブラリ(スレイブ)402は、スレッドA1をCPU#1に実行させる。
 また、スレッド制御ライブラリ(マスタ)401とスレッド制御ライブラリ(スレイブ)402は、スレッドの動作が終了したタイミングでメインスレッド305にスレッドの動作完了を通知する機能を有する。たとえば、スレッド制御ライブラリ(スレイブ)402は、スレッドA1の動作が終了した場合、スレッド制御ライブラリ(マスタ)401に通知する。通知を受けたスレッド制御ライブラリ(マスタ)401は、メインスレッド305にスレッドの動作が終了したことを通知する。
 分岐予測制御ライブラリ403は、スレッド制御ライブラリ(マスタ)401のスレッド起動、スレッド制御ライブラリ(スレイブ)402のスレッド動作終了のタイミングで、共有分岐予測テーブル304のアクセスや、分岐予測情報の転送を行う機能を有する。たとえば、分岐予測制御ライブラリ403は、スレッドA1が起動された場合、共有分岐予測テーブル304にアクセスし、スレッドAに対応する分岐予測テーブル情報を、CPU#1に転送する。
 図5は、独立分岐予測テーブル302の記憶内容の一例を示す説明図である。独立分岐予測テーブル302は、GHR(Global History Register)501、PHT(Pattern History Table)502、BTB(Branch Target Buffer)503を含む。また、独立分岐予測テーブル302は、GHR501~BTB503を操作する回路、機能部として、BTB更新回路504、GHR更新回路505、PHT更新回路506、エントリ選択部507、アドレス一致部508、予測方向判定部509を含む。また、独立分岐予測テーブルI/F303は、分岐予測情報となるGHR501~BTB503を更新する。
 GHR501は、過去数回分の分岐命令が成立したか不成立だったかを記憶するレジスタである。分岐命令の成立時を示す識別子は、成立を示す“T”、不成立を示す“N”となる。たとえば、GHR501は、過去4回の分岐命令の成立結果として、成立、成立、不成立、成立を記憶する。
 PHT502は、分岐命令が成立しやすい傾向にあるか不成立となる傾向にあるのかを数ビットの飽和カウンタ等で表現したテーブルである。PHT502が取り得る値としては、分岐しない可能性が大きいことを示す“2’b00”、分岐しない可能性が小さいことを示す“2’b01”、分岐する可能性が小さいことを示す“2’b10”、分岐する可能性が大きいことを示す“2’b11”である。なお、“2’b”は2進数であることを示している。
 BTB503は、分岐命令ごとに分岐先アドレスを記憶するバッファである。BTB503は、テーブルは、有効フラグ、分岐元命令アドレス、分岐先命令アドレスという3つのフィールドを含む。有効フラグフィールドには、該当のレコードが有効であるか否かを示す値が格納される。たとえば、有効フラグフィールドが“1”であれば、該当のレコードが有効であることを示す。また、有効フラグフィールドが“0”であれば、該当のレコードが無効であることを示す。分岐元命令アドレスフィールドには、分岐命令となるアドレスが格納される。分岐先命令アドレスフィールドには、分岐する場合の分岐先アドレスが格納される。
 BTB更新回路504は、分岐元命令アドレスと分岐先命令アドレスとに基づいて、BTB503を更新する回路である。具体的に、BTB更新回路504は、分岐元命令アドレスの下位ビットを用いてBTB503のレコードを選択し、有効フラグと、分岐元命令アドレスと分岐先命令アドレスを設定する。
 GHR更新回路505は、分岐先方向に基づいて、GHR501を更新する回路である。具体的に、GHR更新回路505は、分岐先方向から分岐命令の成立または不成立を示す1[ビット]の情報を受信し、GHR501に設定する。
 PHT更新回路506は、分岐元命令アドレスと分岐先方向とに基づいて、PHT502を更新する回路である。具体的に、PHT更新回路506は、分岐元命令アドレスの下位ビットを用いてPHT502のレコードを選択し、PHT502内のカウンタを変更する。より詳細には、PHT更新回路506は、分岐先方向が分岐成立を示す情報であればカウンタをインクリメントし、分岐先方向が分岐不成立を示す情報であればカウンタをデクリメントする。
 エントリ選択部507は、予測対象アドレスの下位ビットとGHR501に基づいて、PHT502のレコードを選択する機能を有する。たとえば、エントリ選択部507は、予測対象アドレスの下位ビットにGHR501のビット列を結合して、PHT502のレコードを一意に選択可能なデータを生成する。また、エントリ選択部507は、PHT502のレコードを一意に選択可能なデータとして、予測対象アドレスの下位ビットとGHR501のビット列とのXORを算出してもよい。
 アドレス一致部508は、予測対象アドレスの上位ビットと分岐元命令アドレスとが一致しているか否かを判断する。一致した場合、アドレス一致部508は、アドレスが一致した旨を示す信号を出力する。
 予測方向判定部509は、予測対象アドレスに対応する分岐命令が分岐するか否かを判定する機能を有する。具体的に、予測方向判定部509は、アドレス一致部508からアドレスが一致したという信号を受け取り、かつ、エントリ選択部507によって選択されたレコードが、分岐する可能性がある場合に、分岐が成立するとして分岐先方向を出力する。
 以上の機能により、独立分岐予測テーブル302に予測対象アドレスが入力された場合、独立分岐予測テーブル302は、出力として分岐が成立するか否かを分岐先方向として出力し、また、分岐先命令アドレスを出力する。
 図6は、共有分岐予測テーブル304の記憶内容の一例を示す説明図である。共有分岐予測テーブル304は、タグ情報、分岐予測テーブル情報という2つのフィールドを含む。タグ情報フィールドには、さらに、有効フラグ、スレッド種別識別子という2つのフィールドを含む。有効フラグフィールドには、該当の分岐予測情報が有効であるか否かを示す値が格納される。たとえば、有効フラグフィールドが“1”であれば、分岐予測情報が有効であることを示す。
 スレッド種別識別子フィールドには、スレッド種別を識別する情報が格納される。スレッド種別を識別する情報としては、たとえば、スレッドを一意に特定できる情報として、命令列の先頭アドレスをスレッド種別としてもよい。また、スレッド種別識別子は、相関性のあるスレッドごとに共通の識別子を設定してもよい。具体的なスレッド種別識別子の設定方法については、図7にて後述する。
 分岐予測テーブル情報は、図5に示したGHR501に対応するGHRフィールド、PHT502に対応するPHTフィールド、BTB503に対応するBTBフィールドという3つのフィールドを含む情報である。分岐予測テーブル情報の各フィールドの記憶内容は図5で説明したGHR501~BTB503に等しいため、説明を省略する。
 以下、1スレッド分のタグ情報と分岐予測テーブル情報を合わせて共有分岐予測テーブル304の1エントリと呼称する。たとえば、図6で示す共有分岐予測テーブル304は、エントリ601~エントリ604の合計4エントリが登録されている。
 たとえば、エントリ601は、スレッド種別識別子がスレッドAであり、分岐予測テーブル情報として、GHRフィールドに全て分岐成立、PHTフィールドに“2’b10”、“2’b11”の2レコードが登録されている。さらに、エントリ601は、BTBフィールドに2レコードが登録されている。2レコードの詳細は、分岐元命令アドレス“0x00001000”、分岐先命令アドレス“0x2000C400”からなるレコードと、分岐元命令アドレス“0x00001CC0”、分岐先命令アドレス“0xC0F00000”からなるレコードである。
 また、エントリ602は、スレッド種別識別子がスレッドBであり、分岐予測テーブル情報として、GHRフィールドに分岐成立、分岐不成立、分岐不成立、分岐成立、PHTフィールドに“2’b00”、“2’b11”の2レコードが登録されている。さらに、エントリ602は、BTBフィールドに1レコードが登録されている。1レコードの詳細は、分岐元命令アドレス“0x00001CC0”、分岐先命令アドレス“0xFD010000”からなるレコードである。
 また、エントリ603は、スレッド種別識別子がスレッドCであり、分岐予測テーブル情報として、GHRフィールドに分岐不成立、分岐成立、分岐不成立、分岐不成立、PHTフィールドに“2’b10”、“2’b11”の2レコードが登録されている。さらに、エントリ603は、BTBフィールドに2レコードが登録されている。2レコードの詳細は、分岐元命令アドレス“0x00001000”、分岐先命令アドレス“0x2000C000”からなるレコードと、分岐元命令アドレス“0x00001CC0”、分岐先命令アドレス“0x40000300”からなるレコードである。
 また、エントリ604は、スレッド種別識別子がスレッドDであり、分岐予測テーブル情報として、GHRフィールドに全て分岐成立、PHTフィールドに“2’b00”、“2’b01”の2レコードが登録されている。なお、エントリ604のBTBフィールドには、有効なレコードが存在しない。
 図7は、スレッド種別識別子の設定方法を示す説明図である。図7では、マルチコアプロセッサシステム100が画像処理を行う場合におけるスレッド種別識別子の設定方法について説明する。マルチコアプロセッサシステム100は、画像701について特定の処理を行うことを想定する。特定の処理とは、たとえば、色調補正であったり、色相彩度変換であったり、どのような処理であってもよい。
 マルチコアプロセッサシステム100は、画像701を領域1~領域4に分割して処理を行う。分割された領域について、CPU#0が領域1に対してスレッドA種別に属するスレッド、スレッドB種別に属するスレッド、スレッドC種別に属するスレッドの順に実行する。以下、説明を簡略化するため、実行されるスレッドは、それぞれスレッドA1、スレッドB1、スレッドC1であると想定する。同様に、CPU#1が領域2に対して、CPU#2が領域3に対して、スレッドA1、スレッドB1、スレッドC1の順に実行する。
 このとき、特定のエントリのスレッド種別識別子がスレッドA種別に設定されると、特定のエントリは、グループ702に属するスレッド群によってアクセスされることになる。また、特定のエントリのスレッド種別識別子を、領域1を示す識別子に設定すると、特定のエントリが、グループ703に属するスレッド群によってアクセスされることになる。領域1を示す識別子としては、領域1の先頭アドレスや、ファイルシステム上のファイルポインタ等である。
 同様に、特定のエントリのスレッド種別識別子を、領域2を示す識別子に設定すると、特定のエントリが、グループ704に属するスレッド群によってアクセスされる。また、特定のエントリのスレッド種別識別子を、領域3を示す識別子に設定すると、特定のエントリが、グループ705に属するスレッド群によってアクセスされる。
 このように、スレッド種別識別子をデータに関する識別子に設定すると、データの分類によって分岐命令の結果が変化する場合、マルチコアプロセッサシステム100は、予測精度を向上することができる。
 図8は、マルチコアプロセッサシステム100が正常動作を行う場合のシーケンス図である。図8では、CPU#0がメインスレッド305、スレッド制御ライブラリ(マスタ)401、分岐予測制御ライブラリ403を実行する。また、CPU#1が独立分岐予測テーブル302#1にアクセスし、スレッド制御ライブラリ(スレイブ)402、スレッド1を実行する。
 メインスレッド305は、スレッド起動要求をスレッド制御ライブラリ(マスタ)401に通知する(ステップS801)。通知を受け取ったスレッド制御ライブラリ(マスタ)401は、さらにスレッド起動準備要求を分岐予測制御ライブラリ403に通知する(ステップS802)。
 スレッド起動準備要求を受け取った分岐予測制御ライブラリ403は、起動要求のあったスレッド種別識別子を用いて、共有分岐予測テーブル304から分岐予測情報を読み出す(ステップS803)。分岐予測制御ライブラリ403は、読み出し完了(ステップS804)後、独立分岐予測テーブル302#1に、読み出した分岐予測情報を書き込む(ステップS805)。分岐予測制御ライブラリ403は、書き込み完了(ステップS806)後、スレッド起動準備完了をスレッド制御ライブラリ(マスタ)401に通知する(ステップS807)。
 スレッド起動準備完了を受け取ったスレッド制御ライブラリ(マスタ)401は、スレッド起動要求をスレッド制御ライブラリ(スレイブ)402#1に通知し(ステップS808)、メインスレッド305にスレッド起動完了を通知する(ステップS809)。
 スレッド起動要求を受け取ったスレッド制御ライブラリ(スレイブ)402は、CPU#1にてスレッド1を起動させる(ステップS810)。CPU#1は、スレッド1実行中では、独立分岐予測テーブル302#1にアクセスし、分岐予測を行う。
 スレッド1の動作が終了すると、スレッド制御ライブラリ(スレイブ)402は、スレッド動作終了を受け取り(ステップS811)、スレッド制御ライブラリ(マスタ)401にスレッド動作終了を通知する(ステップS812)。
 スレッド動作終了を受け取ったスレッド制御ライブラリ(マスタ)401は、メインスレッドにスレッド動作終了を通知しつつ(ステップS813)、分岐予測制御ライブラリ403にスレッド動作終了通知を通知する(ステップS814)。通知を受け取った分岐予測制御ライブラリ403は、独立分岐予測テーブル302#1から分岐予測情報を読み出す(ステップS815)。
 分岐予測制御ライブラリ403は、読み出し完了(ステップS816)後、共有分岐予測テーブル304に、読み出した分岐予測情報を書き込む(ステップS817)。分岐予測制御ライブラリ403は、書き込み完了(ステップS818)後、スレッド動作終了完了をスレッド制御ライブラリ(マスタ)401に通知する(ステップS819)。
 図9は、マルチコアプロセッサシステム100が中断動作を行う場合のシーケンス図である。図9における中断動作のシーケンス図において、ステップS901~ステップS910で示すシーケンスは、ステップS801~ステップS810で示すシーケンスと同様であるため、説明を省略する。
 メインスレッド305がスレッド制御ライブラリ(マスタ)401にスレッド中断要求を通知する(ステップS911)。通知を受け取ったスレッド制御ライブラリ(マスタ)401は、スレッド制御ライブラリ(スレイブ)402#1にスレッド中断要求を通知し(ステップS912)、メインスレッド305にスレッド中断応答を通知する(ステップS913)。
 スレッド中断要求を受け取ったスレッド制御ライブラリ(スレイブ)402#1は、スレッド1を中断させ(ステップS914)、スレッド中断終了をスレッド制御ライブラリ(マスタ)401に通知する(ステップS915)。スレッド中断終了を受け取ったスレッド制御ライブラリ(マスタ)401は、スレッド動作中断通知を通知する(ステップS916)。スレッド動作中断通知を受け取った分岐予測制御ライブラリ403は、共有分岐予測テーブル304を更新せずに、スレッド動作中断完了をスレッド制御ライブラリ(マスタ)401に通知する(ステップS917)。スレッド動作中断完了を受け取ったスレッド制御ライブラリ(マスタ)401は、メインスレッド305にスレッド動作中断完了を通知する(ステップS918)。
 次に、図8、図9で示したシーケンス図の動作を満たすような分岐予測制御ライブラリ403の処理を図10、図11にて示す。図10がスレッドの起動処理のフローチャートを示し、図11がスレッドの動作終了処理のフローチャートを示す。なお、スレッドの動作終了処理が発生する場合としては、スレッドの処理が完了する場合、スレッドの処理が中断されて終了する場合である。
 図10は、スレッドの起動処理を示すフローチャートである。CPU#0は、起動するスレッドのスレッド種別識別子を取得する(ステップS1001)。取得後、CPU#0は、スレッド種別識別子を用いて共有分岐予測テーブル304にアクセスする(ステップS1002)。CPU#0は、アクセスした結果、有効な分岐予測情報が存在するか否か判断する(ステップS1003)。有効な分岐予測情報が存在する場合(ステップS1003:Yes)、CPU#0は、共有分岐予測テーブル304から分岐予測情報を読み出す(ステップS1004)。
 有効な分岐予測情報がない場合(ステップS1003:No)、CPU#0は、共有分岐予測テーブル304の空きエントリを検索する(ステップS1005)。なお、空きエントリとは、有効フラグが“0”のエントリのことである。検索後、CPU#0は、空きエントリが存在するか否かを判断する(ステップS1006)。空きエントリが存在する場合(ステップS1006:Yes)、CPU#0は、空きエントリをクリアし、取得したスレッド種別識別子を設定して有効化し(ステップS1007)、クリアされた分岐予測情報を読み出す(ステップS1008)。
 なお、エントリをクリアするとは、具体的には、分岐予測情報の予測結果を中立状態にすることである。たとえば、CPU#0は、PHT502を分岐しない(可能性小)に設定する。また、エントリのクリアについては、独立分岐予測テーブル302の仕様にしたがって予測結果をクリアしてもよい。
 空きエントリが存在しない場合(ステップS1006:No)、または、ステップS1004、ステップS1008の終了後、CPU#0は、スレッドを実行するCPUを決定する(ステップS1009)。なお、スレッドを実行するCPUの決定方法としては、OS等が有するスケジューラが持つ機能によって決定される。
 決定後、CPU#0は、分岐予測情報が読み出せているか否かを判断する(ステップS1010)。分岐予測情報が読み出せている場合(ステップS1010:Yes)、CPU#0は、スレッドを実行するCPUの独立分岐予測テーブル302に分岐予測情報を書き込む(ステップS1011)。書き込み後、または分岐予測情報が読み出せていない場合(ステップS1010:No)、CPU#0は、スレッドを実行するCPUにスレッド実行を要求し(ステップS1012)、スレッドの起動処理を終了する。
 なお、スレッドの起動処理は、OSのスケジューリング機能によって、別のスレッドに切り替わる際の切替後のスレッドに対しても発生する。この場合、CPU#0は、ステップS1001の処理を、「切替後のスレッドのスレッド種別識別子を取得」として実行する。また、スレッドの起動処理は、スレッドに割り当てられたタイムスライスが満了した際に発生したスレッド切替において、切替後のスレッドに対して行ってもよい。また、スレッドの起動処理は、ISR(Interrupt Service Routine)によって割り込まれた後の、復帰後のスレッドに対して行ってもよい。
 図11は、スレッドの動作終了処理を示すフローチャートである。CPU#0は、スレッドを実行したCPUから動作終了の通知を受け取る(ステップS1101)。通知を受け取った後、CPU#0は、スレッドが中断されて終了したか否かを判断する(ステップS1102)。スレッドが中断されずに終了した場合(ステップS1102:No)、CPU#0は、スレッドを実行したCPUの独立分岐予測テーブル302から分岐予測情報を読み出す(ステップS1103)。読出し後、CPU#0は、終了したスレッドのスレッド種別識別子を取得する(ステップS1104)。
 取得後、CPU#0は、スレッド種別識別子を用いて共有分岐予測テーブル304にアクセスする(ステップS1105)。アクセスの結果、CPU#0は、有効な分岐予測情報が存在するか否かを判断する(ステップS1106)。有効な分岐予測情報が存在する場合(ステップS1106:Yes)、CPU#0は、共有分岐予測テーブル304の分岐予測情報を独立分岐予測テーブル302の分岐予測情報で上書きする(ステップS1107)。上書き後、有効な分岐予測情報が存在しない場合(ステップS1106:No)、またはスレッドが中断されて終了した場合(ステップS1102:Yes)、CPU#0は、スレッドの後始末の処理を実行する(ステップS1108)。実行後、CPU#0は、スレッドの動作終了処理を終了する。
 なお、スレッドの動作終了処理は、OSのスケジューリング機能によって、別のスレッドに切り替わる際の切替前のスレッドに対しても発生する。この場合、CPU#0は、ステップS1101の処理を、「スレッドを実行するCPUからスレッド切替の通知」として実行し、ステップS1104の処理を、「切替前のスレッドのスレッド種別識別子を取得」として実行する。さらに、CPU#0は、ステップS1108の処理を実行しない。
 以上説明したように、マルチコアプロセッサシステム、および分岐予測方法によれば、スレッドごとに分岐予測結果の履歴を持ち、コアがスレッドを実行する度に、対応する履歴をコア内の分岐予測の履歴を記憶するメモリに設定し、スレッドの終了時に回収する。これにより、マルチコアプロセッサシステムは、並列処理の粒度が細かくすぐ終了するスレッドでも履歴を蓄積でき、予測精度を向上できる。
 また、マルチコアプロセッサシステムは、投機実行を行ったスレッドが中断された場合に、投機実行を行ったスレッドが蓄積していた分岐予測の履歴を破棄してもよい。これにより、マルチコアプロセッサシステムは、現在蓄積中の分岐予測結果の履歴の中に、実行不要であったスレッドによる分岐予測の履歴を混合させずに済み、より正確な分岐予測結果の履歴を蓄積することができる。
 また、マルチコアプロセッサシステムは、分岐予測情報を、各CPUで共有された分岐予測の履歴を記憶するメモリから、各CPU内の分岐予測の履歴を記憶するメモリに転送するバスを有していてもよい。これにより、マルチコアプロセッサシステムは、分岐予測情報の転送を、他のデータの転送に阻害されずに行える。
 また、マルチコアプロセッサシステムは、各CPUで共有された分岐予測の履歴を記憶するメモリ内にスレッドに対応する分岐予測情報が存在しない場合、分岐予測情報が格納されていない領域をクリアし、スレッドに対応する分岐予測情報として読み出してもよい。これにより、マルチコアプロセッサシステムは、空き領域を有効利用することができる。
 また、マルチコアプロセッサシステムは、スレッドの粒度を細かくしても、分岐予測の精度を維持することができる。たとえば、特定のコアが細粒度スレッドを実行し、他のコアでも細粒度スレッドを実行する場合を想定する。従来技術では、他のコアは、特定のコアで実行された細粒度スレッドの分岐予測情報を参照できないため、予測精度が悪くなってしまっていた。実施の形態1では、他のコアは、特定のコアで実行された細粒度スレッドの分岐予測情報を参照でき、予測精度を向上することができる。
 また、マルチコアプロセッサシステムは、共有分岐予測テーブルのサイズが、各コアが有している独立分岐予測テーブルのサイズのN倍である場合、従来技術における、コアが保持する分岐予測情報用のメモリをN倍にしたことと同じ分岐予測精度を実現できる。共有分岐予測テーブルに使用するメモリは、コアが保持する分岐予測情報用のメモリよりアクセスされる頻度が低いため、低速のメモリを使用することができ、コストを削減することができる。
(実施の形態2の説明)
 図12は、実施の形態2にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。実施の形態2にかかるマルチコアプロセッサシステム100は、共有分岐予測テーブル304の格納場所が、実施の形態1にマルチコアプロセッサシステム100のハードウェアと異なる。実施の形態2にかかるマルチコアプロセッサシステム100は、共有分岐予測テーブル304の格納場所以外に関して、実施の形態1にかかるマルチコアプロセッサシステム100と同一のハードウェアを有し、同一の機能を有するため、説明を省略する。
 実施の形態2にかかるマルチコアプロセッサシステム100では、共有分岐予測テーブル304をメインメモリ301に格納する。また、独立分岐予測テーブル302は、I/O空間にマッピングし、各CPUからアクセス可能であるとする。また、分岐予測情報バス211とバス210が独立分岐予測テーブルI/F303#Bによって接続されている。たとえば、CPU#0は、独立分岐予測テーブルI/F303#0と独立分岐予測テーブルI/F303#Bを経由して共有分岐予測テーブル304にアクセスする。
 分岐予測制御ライブラリ403は、スレッド起動時にて、メインメモリ301上の共有分岐予測テーブル304から起動するスレッドの分岐予測情報を読み出す。続けて、分岐予測制御ライブラリ403は、I/O空間上のスレッドを実行するCPUの独立分岐予測テーブル302に共有分岐予測テーブル304を書き込む。これにより、実施の形態1にかかるマルチコアプロセッサシステム100に比べ、ハードウェアの追加コストを削減することができる。また、実施の形態2にかかるマルチコアプロセッサシステム100は、メインメモリ301に空きがある場合、共有分岐予測テーブル304を記憶する記憶素子を追加しなくてよい。
(実施の形態3の説明)
 図13は、実施の形態3にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。実施の形態3にかかるマルチコアプロセッサシステム100は、共有分岐予測テーブル304の格納場所がメインメモリ301であり、さらにその一部が共有分岐予測テーブルキャッシュ1301として、共有分岐予測レジスタ212に格納されている。共有分岐予測テーブルキャッシュ1301は、共有分岐予測テーブル304と同一のフィールドを有する。実施の形態3にかかるマルチコアプロセッサシステム100は、共有分岐予測テーブル304の格納場所以外に関して、実施の形態1にかかるマルチコアプロセッサシステム100と同一のハードウェアを有し、同一の機能を有するため、説明を省略する。
 図14は、実施の形態3にかかるスレッドの起動処理を示すフローチャート(その1)である。なお、実施の形態3にかかるスレッドの起動処理のうち、ステップS1406~ステップS1411は、図10で示したステップS1003~ステップS1008と、ステップS1409:Noの処理後を除いて等しいため、説明を省略する。
 CPU#0は、起動するスレッドのスレッド種別識別子を取得する(ステップS1401)。取得後、CPU#0は、スレッド種別識別子を用いて共有分岐予測テーブルキャッシュ1301にアクセスする(ステップS1402)。CPU#0は、アクセスした結果、有効な分岐予測情報が存在するか否か判断する(ステップS1403)。有効な分岐予測情報が存在する場合(ステップS1403:Yes)、CPU#0は、共有分岐予測テーブルキャッシュ1301から分岐予測情報を読み出す(ステップS1404)。読み出し後、CPU#0は、ステップS1503の処理に移行する。
 有効な分岐予測情報がない場合(ステップS1403:No)、CPU#0は、スレッド種別識別子を用いて、メインメモリ301の共有分岐予測テーブル304にアクセスする(ステップS1405)。ステップS1407、またはステップS1411の終了後、CPU#0は、ステップS1501の処理に移行する。また、ステップS1409:Noの処理後、CPU#0は、ステップS1503の処理に移行する。
 図15は、実施の形態3にかかるスレッドの割り当て開始を示すフローチャート(その2)である。なお、ステップS1503~ステップS1506は、図10で示したステップS1009~ステップS1012と等しいため、説明を省略する。
 CPU#0は、置換アルゴリズムを用いて、共有分岐予測テーブルキャッシュ1301の1エントリを選択する(ステップS1501)。なお、置換アルゴリズムは、たとえば、LRU(Least Recently Used)、LFU(Least Frequently Used)等を適用してもよい。選択後、CPU#0は、選択したエントリを、メインメモリ301の共有分岐予測テーブル304に上書きする(ステップS1502)。
 図16は、実施の形態3にかかるスレッドの動作終了処理を示すフローチャートである。なお、実施の形態3にかかるスレッドの動作終了処理のうち、ステップS1601~ステップS1604の処理は、図11で示したステップS1101~ステップS1104と等しいため、説明を省略する。同様に、ステップS1609~ステップS1611の処理は、ステップS1106~ステップS1108と等しいため、説明を省略する。
 CPU#0は、スレッド種別識別子を用いて共有分岐予測テーブルキャッシュ1301にアクセスする(ステップS1605)。アクセス後、CPU#0は、有効な分岐予測情報が存在するか否かを判断する(ステップS1606)。有効な分岐予測情報が存在する場合(ステップS1606:Yes)、CPU#0は、共有分岐予測テーブルキャッシュ1301の分岐予測情報を独立分岐予測テーブル302の分岐予測情報で上書きし(ステップS1607)、ステップS1611の処理に移行する。
 有効な分岐予測情報が存在しない場合(ステップS1606:No)、CPU#0は、スレッド種別識別子を用いてメインメモリ301の共有分岐予測テーブル304にアクセスする(ステップS1608)。アクセス後、CPU#0は、ステップS1609の処理に移行する。
 以上のように、実施の形態3にかかるマルチコアプロセッサシステム100は、スレッド起動に時間的局所性が存在する場合、スレッド起動、スレッド動作終了にかかる性能上のオーバーヘッドを削減することができる。
(実施の形態4の説明)
 実施の形態1~実施の形態3にかかるマルチコアプロセッサシステム100では、現在実行されるスレッド種別に基づいて分岐予測情報を取得していた。実施の形態4にかかるマルチコアプロセッサシステム100は、過去のスレッドの起動履歴に基づいて分岐予測情報を取得する。
 図17は、実施の形態4にかかるマルチコアプロセッサシステム100のハードウェアを示すブロック図である。実施の形態4にかかるマルチコアプロセッサシステム100では、実施の形態1にかかる共有分岐予測テーブル304の代わりに共有分岐予測テーブル1701を含む。共有分岐予測テーブル1701の詳細については、図18にて後述する。また、実施の形態4にかかるマルチコアプロセッサシステム100は、共有分岐予測テーブル304以外に関して、実施の形態1にかかるマルチコアプロセッサシステム100と同一であり、また、読出部312を除いて同一の機能を有するため、説明を省略する。
 読出部312は、検出部311によって検出された第1スレッドと、第1スレッドより前に実行された第2スレッドと、に対応する分岐予測情報を各CPUで共有された分岐予測の履歴を記憶するメモリから読み出す。
 図18は、実施の形態4にかかる共有分岐予測テーブル1701の記憶内容の一例を示す説明図である。共有分岐予測テーブル1701は、共有分岐予測テーブル304のスレッド種別識別子の代わりにスレッド起動順序識別子フィールドを含む。共有分岐予測テーブル1701における他のフィールドについては、共有分岐予測テーブル304の他のフィールドと同一の記憶内容を記憶しているため、説明を省略する。
 スレッド起動順序識別子フィールドは、スレッドの起動される順番でスレッド種別識別子群が格納されている。たとえば、エントリ1801のスレッド起動順序識別子フィールドは、今回起動されるスレッド種別識別子がスレッドAであり、その前にスレッドB種別のスレッドが起動され、さらにその前にスレッドC種別のスレッドが起動されたことを示している。以下、説明を簡略化するため、各スレッド種別で実行されるスレッドは、それぞれスレッドA1、スレッドB1、スレッドC1、スレッドD1であると想定する。同様に、エントリ1802のスレッド起動順序識別子フィールドは、今回起動されるスレッドがスレッドB1であり、その前にスレッドB1が起動され、さらにその前にスレッドA1が起動されたということを示している。
 また、エントリ1803のスレッド起動順序識別子フィールドは、今回起動されるスレッドがスレッドC1であり、その前にスレッドB1が起動され、さらにその前にスレッドA1が起動されたということを示している。最後に、エントリ1804のスレッド起動順序識別子フィールドは、今回起動されるスレッドがスレッドC1であり、その前にスレッドB1が起動され、さらにその前にスレッドD1が起動されたということを示している。
 実施の形態4にかかるマルチコアプロセッサシステム100は、以上説明したように、共有分岐予測テーブル1701にアクセスしてスレッドの起動処理、動作終了処理を実行する。具体的なフローチャートに関しては、図10、図11にて示したフローチャートにて、スレッド種別識別子をスレッド起動順序識別子に置き換えることで対応可能であるため、説明を省略する。
 以上説明したように、実施の形態4にかかるマルチコアプロセッサシステムによれば、スレッドの起動順序に基づいて分岐予測情報を設定する。これにより、マルチコアプロセッサシステムは、スレッドの起動順序と個々の分岐の傾向に相関性がある場合、分岐予測精度を向上させることができる。
 なお、本実施の形態1~実施の形態4で説明した分岐予測方法は、予め用意されたプログラムをパーソナル・コンピュータやワークステーション等のコンピュータで実行することにより実現することができる。本分岐予測方法を実行するプログラムは、ハードディスク、フレキシブルディスク、CD-ROM、MO、DVD等のコンピュータで読み取り可能な記録媒体に記録され、コンピュータによって記録媒体から読み出されることによって実行される。また本分岐予測方法を実行するプログラムは、インターネット等のネットワークを介して配布してもよい。
 #0、#1、#2 CPU
 100 マルチコアプロセッサシステム
 208 I/F
 210 バス
 211 分岐予測情報バス
 212 分岐予測情報レジスタ
 301 メインメモリ
 302 独立分岐予測テーブル
 303 独立分岐予測テーブルI/F
 304 共有分岐予測テーブル
 305 メインスレッド
 306 サブスレッド
 311 検出部
 312 読出部
 313 書込部
 314 読出部
 315 書込部

Claims (10)

  1.  複数のCPUと、
     前記複数のCPUのそれぞれに対応して設けられる複数の分岐予測メモリと、
     前記複数のCPUで実行される複数のスレッドのそれぞれに対応する分岐予測情報を格納する共有分岐予測メモリと、
     を含み、
     前記複数のCPUの内の第1CPUによって実行される前記複数のスレッドの内の第1スレッドに対応する分岐予測情報を前記共有分岐予測メモリから前記第1CPUに対応する前記分岐予測メモリに設定すること
     を特徴とするマルチコアプロセッサシステム。
  2.  さらに、前記分岐予測情報を前記共有分岐予測メモリから前記分岐予測メモリに転送するバスを含むこと
     を特徴とする請求項1に記載のマルチコアプロセッサシステム。
  3.  前記第1スレッドの動作終了時、前記第1CPUに対応する前記分岐予測メモリの分岐予測情報が前記共有分岐予測メモリに書き込まれること
     を特徴とする請求項1または請求項2に記載のマルチコアプロセッサシステム。
  4.  前記共有分岐予測メモリは、メインメモリに対応すること
     を特徴とする請求項1乃至請求項3の何れか一に記載のマルチコアプロセッサシステム。
  5.  さらに、前記メインメモリ内の前記分岐予測情報の少なくとも一部を格納する共有分岐予測キャッシュを含むこと
     を特徴とする請求項4に記載のマルチコアプロセッサシステム。
  6.  前記第1スレッドに対応する分岐予測情報は、前記第1スレッドより前に実行された第2スレッドに関する分岐予測情報をも含むこと
     を特徴とする請求項1乃至請求項5の何れか一に記載のマルチコアプロセッサシステム。
  7.  複数のCPUの内の第1CPUは、
     第1スレッドに対応する分岐予測情報を共有分岐予測メモリから前記第1CPUに対応する分岐予測メモリに書き込み、
     前記第1スレッドに対応する分岐予測情報に基づいて、分岐予測を行って前記第1スレッドを実行すること
     を特徴とする分岐予測方法。
  8.  前記第1スレッドの動作終了時、前記第1CPUに対応する前記分岐予測メモリの分岐予測情報を前記共有分岐予測メモリに書き込むこと
     を特徴とする請求項7に記載の分岐予測方法。
  9.  前記共有分岐予測メモリ内に有効な前記第1スレッドに対応する分岐予測情報が存在しないとき、分岐予測情報が格納されていないテーブルをクリアし、前記テーブルから前記第1スレッドに対応する分岐予測情報を読み出すこと
     を特徴とする請求項7または請求項8に記載の分岐予測方法。
  10.  前記第1スレッドに対応する分岐予測情報は、前記第1スレッドより前に実行された第2スレッドに関する分岐予測情報をも含むこと
     を特徴とする請求項7乃至請求項9の何れか一に記載の分岐予測方法。
PCT/JP2011/056659 2011-03-18 2011-03-18 マルチコアプロセッサシステム、および分岐予測方法 WO2012127589A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2013505649A JPWO2012127589A1 (ja) 2011-03-18 2011-03-18 マルチコアプロセッサシステム、および分岐予測方法
PCT/JP2011/056659 WO2012127589A1 (ja) 2011-03-18 2011-03-18 マルチコアプロセッサシステム、および分岐予測方法
US14/029,511 US20140019738A1 (en) 2011-03-18 2013-09-17 Multicore processor system and branch predicting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2011/056659 WO2012127589A1 (ja) 2011-03-18 2011-03-18 マルチコアプロセッサシステム、および分岐予測方法

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/029,511 Continuation US20140019738A1 (en) 2011-03-18 2013-09-17 Multicore processor system and branch predicting method

Publications (1)

Publication Number Publication Date
WO2012127589A1 true WO2012127589A1 (ja) 2012-09-27

Family

ID=46878786

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2011/056659 WO2012127589A1 (ja) 2011-03-18 2011-03-18 マルチコアプロセッサシステム、および分岐予測方法

Country Status (3)

Country Link
US (1) US20140019738A1 (ja)
JP (1) JPWO2012127589A1 (ja)
WO (1) WO2012127589A1 (ja)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021516384A (ja) * 2018-02-13 2021-07-01 ▲龍▼芯中科技▲術▼有限公司Loongson Technology Corporation Limited 分岐予測回路及びその制御方法

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9430241B2 (en) 2012-06-15 2016-08-30 International Business Machines Corporation Semi-exclusive second-level branch target buffer
US9280351B2 (en) 2012-06-15 2016-03-08 International Business Machines Corporation Second-level branch target buffer bulk transfer filtering
US9298465B2 (en) 2012-06-15 2016-03-29 International Business Machines Corporation Asynchronous lookahead hierarchical branch prediction
US9563430B2 (en) 2014-03-19 2017-02-07 International Business Machines Corporation Dynamic thread sharing in branch prediction structures
US9639368B2 (en) 2014-06-13 2017-05-02 International Business Machines Corporation Branch prediction based on correlating events
JP6515771B2 (ja) * 2015-10-07 2019-05-22 富士通コネクテッドテクノロジーズ株式会社 並列処理装置及び並列処理方法
US10540181B2 (en) 2018-01-19 2020-01-21 Marvell World Trade Ltd. Managing branch prediction information for different contexts
US10599437B2 (en) 2018-01-19 2020-03-24 Marvell World Trade Ltd. Managing obscured branch prediction information
GB2574042B (en) 2018-05-24 2020-09-09 Advanced Risc Mach Ltd Branch Prediction Cache
US11360812B1 (en) * 2018-12-21 2022-06-14 Apple Inc. Operating system apparatus for micro-architectural state isolation
US11068273B2 (en) * 2019-09-03 2021-07-20 Microsoft Technology Licensing, Llc Swapping and restoring context-specific branch predictor states on context switches in a processor
US11263114B2 (en) * 2019-09-24 2022-03-01 International Business Machines Corporation Method and technique to find timing window problems

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001236225A (ja) * 2000-02-22 2001-08-31 Fujitsu Ltd 演算装置及び分岐予測方法並びに情報処理装置
JP2001249806A (ja) * 2000-02-22 2001-09-14 Hewlett Packard Co <Hp> 予測情報管理方法
JP2004326785A (ja) * 2003-04-28 2004-11-18 Internatl Business Mach Corp <Ibm> 同時マルチスレッドのための分割分岐履歴テーブルおよびカウント・キャッシュ
JP2006053830A (ja) * 2004-08-13 2006-02-23 Toshiba Corp 分岐予測装置および分岐予測方法
JP2009535750A (ja) * 2006-05-04 2009-10-01 インターナショナル・ビジネス・マシーンズ・コーポレーション 多形的分岐予測子を実装するための方法および装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5949995A (en) * 1996-08-02 1999-09-07 Freeman; Jackie Andrew Programmable branch prediction system and method for inserting prediction operation which is independent of execution of program code
US7877587B2 (en) * 2006-06-09 2011-01-25 Arm Limited Branch prediction within a multithreaded processor
US8433885B2 (en) * 2009-09-09 2013-04-30 Board Of Regents Of The University Of Texas System Method, system and computer-accessible medium for providing a distributed predicate prediction
US20110078425A1 (en) * 2009-09-25 2011-03-31 Shah Manish K Branch prediction mechanism for predicting indirect branch targets

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001236225A (ja) * 2000-02-22 2001-08-31 Fujitsu Ltd 演算装置及び分岐予測方法並びに情報処理装置
JP2001249806A (ja) * 2000-02-22 2001-09-14 Hewlett Packard Co <Hp> 予測情報管理方法
JP2004326785A (ja) * 2003-04-28 2004-11-18 Internatl Business Mach Corp <Ibm> 同時マルチスレッドのための分割分岐履歴テーブルおよびカウント・キャッシュ
JP2006053830A (ja) * 2004-08-13 2006-02-23 Toshiba Corp 分岐予測装置および分岐予測方法
JP2009535750A (ja) * 2006-05-04 2009-10-01 インターナショナル・ビジネス・マシーンズ・コーポレーション 多形的分岐予測子を実装するための方法および装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021516384A (ja) * 2018-02-13 2021-07-01 ▲龍▼芯中科技▲術▼有限公司Loongson Technology Corporation Limited 分岐予測回路及びその制御方法
JP7210600B2 (ja) 2018-02-13 2023-01-23 ▲龍▼芯中科技▲術▼有限公司 分岐予測回路及びその制御方法

Also Published As

Publication number Publication date
JPWO2012127589A1 (ja) 2014-07-24
US20140019738A1 (en) 2014-01-16

Similar Documents

Publication Publication Date Title
WO2012127589A1 (ja) マルチコアプロセッサシステム、および分岐予測方法
US11892949B2 (en) Reducing cache transfer overhead in a system
US9367311B2 (en) Multi-core processor system, synchronization control system, synchronization control apparatus, information generating method, and computer product
TWI646422B (zh) 在處理器中之免消歧義失序載入/儲存佇列方法、微處理器、和非暫態性電腦可讀取儲存媒體
WO2011158320A1 (ja) マルチコアプロセッサシステム、キャッシュコヒーレンシ制御方法、およびキャッシュコヒーレンシ制御プログラム
US10956328B2 (en) Selective downstream cache processing for data access
KR20090025295A (ko) 가상 트랜잭션 메모리를 위한 글로벌 오버플로우 방법
US9448934B2 (en) Affinity group access to global data
US20180081814A1 (en) Quality of cache management in a computer
US8806135B1 (en) Load store unit with load miss result buffer
US9606923B2 (en) Information processing device with shared memory, memory order guarantee method using counters fence instructions in relation to cache-oriented requests, and recording medium storing program
US20140082624A1 (en) Execution control method and multi-processor system
JP5811211B2 (ja) マルチコアプロセッサシステム、マルチコアプロセッサシステムの制御方法、およびマルチコアプロセッサシステムの制御プログラム
JP5614483B2 (ja) マルチコアプロセッサシステム、キャッシュコヒーレンシ制御方法、およびキャッシュコヒーレンシ制御プログラム
US11782919B2 (en) Using metadata presence information to determine when to access a higher-level metadata table
JP5541491B2 (ja) マルチプロセッサ、これを用いたコンピュータシステム、およびマルチプロセッサの処理方法
US20140244940A1 (en) Affinity group access to global data

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

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2013505649

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11861367

Country of ref document: EP

Kind code of ref document: A1