WO2012144149A1 - マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード - Google Patents

マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード Download PDF

Info

Publication number
WO2012144149A1
WO2012144149A1 PCT/JP2012/002401 JP2012002401W WO2012144149A1 WO 2012144149 A1 WO2012144149 A1 WO 2012144149A1 JP 2012002401 W JP2012002401 W JP 2012002401W WO 2012144149 A1 WO2012144149 A1 WO 2012144149A1
Authority
WO
WIPO (PCT)
Prior art keywords
thread
switching
state
context
processor
Prior art date
Application number
PCT/JP2012/002401
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 パナソニック株式会社
Publication of WO2012144149A1 publication Critical patent/WO2012144149A1/ja

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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Definitions

  • the present invention relates to a multi-thread processor that executes a plurality of threads in parallel and a multi-processor system having a plurality of processor cores, and more particularly to a thread switching device.
  • information such as registers and program counters used by each thread is called a context.
  • a multi-thread processor is implemented with multiple context units for storing the context for each thread.
  • the multi-thread processor assigns a thread to each context unit and executes a plurality of threads simultaneously.
  • a thread is assigned to each processor core, and multiple threads are executed simultaneously.
  • multi-thread processors and multi-processor systems there are waiting threads that are not assigned to context units.
  • the waiting thread to be executed next is selected from one or more of these waiting threads.
  • multi-thread processors and the like there are also executing threads assigned to the context unit. From among a plurality of such running threads, a running thread that is in the standby state next is selected. Then, the selected two threads are switched.
  • Patent Document 1 and Patent Document 2 in order to increase processing efficiency in a multi-thread processor or a multi-processor system, the following is performed in scheduling. This means that a thread to be switched is selected based not only on the priority inherent to the process but also on the priority taking into account the past execution history of the thread and the execution state of the processor.
  • JP 2010-205046 A Japanese Patent No. 4086846
  • the process relates to a running thread that is assigned to the selected context unit that is next waiting. That is, after the executing thread safely stops the execution of the instruction, it is necessary to save the thread context.
  • the thread scheduling is completed and the thread switching is started, the processing of the selected thread being executed to be switched exists in the pipeline and remains. If the remaining processing is an incomplete memory access in the middle of processing, or if it is an interrupt or exception processing, thread switching may not be performed.
  • Patent Document 1 and Patent Document 2 the execution state of the processor is referred only when scheduling is performed. For this reason, these patent documents 1 etc. have the following subject.
  • the status of the selected thread that is being switched is in a thread switching prohibition state in which thread switching cannot be performed due to incomplete memory access or interrupt or exception processing. There may be. In this case, there is a problem that the execution of the waiting thread selected by the scheduling cannot be started, and the processing efficiency is lowered.
  • an object of the present invention is to provide a multithread processor or the like with higher processing efficiency.
  • the execution device (one of the multi-thread processor and the multi-processor system) executes the first and second threads, and one or more threads that are in an executable state
  • a thread scheduling device that selects the first thread from the first thread and requests switching between the selected first thread and the second thread being executed; and a context of the second thread being executed;
  • a context switch device that swaps the context of the first thread in an executable state, and the context switch device is configured to switch the thread after the request for switching is made.
  • a thread scheduling device that selects at least one thread from threads that are in an executable state and instructs switching to a thread that is being executed
  • a context switch device that switches a context and an executable thread context, and a thread switching request is output from the thread scheduling device;
  • the context switch device switches the context and the thread scheduling until the thread switching prohibition factor is released. Or waits for notification of thread switching acceptance of the device, and judging whether to notify the rescheduling request to the thread scheduling device by a factor of the thread switching inhibition.
  • the thread scheduling device restarts if a thread having a higher priority than the thread that has requested thread switching is not newly executable. If a thread with a higher priority than a thread that has requested thread switching is requested to switch to a running thread other than the thread for which scheduling is requested, priority is given to the thread. It is characterized by requesting switching between a thread having a high degree and an executing thread different from the thread requested to be rescheduled.
  • processing to be performed can be performed at higher speed.
  • FIG. 1 is a block diagram showing a configuration example of a multi-thread processor according to the present invention.
  • FIG. 2 is a flowchart showing a flow of a general thread switching process in the context switch unit according to the present invention.
  • FIG. 3 is a block diagram showing a configuration example of a multiprocessor system according to the present invention.
  • FIG. 4 is a flowchart illustrating an example of thread switching processing in the context switch unit when the thread switching prohibition factor is memory access.
  • FIG. 5 is a flowchart illustrating an example of thread switching processing in the context switch unit when the thread switching prohibition factor is memory access.
  • FIG. 6 is a flowchart illustrating an example of thread switching processing in the context switching unit when the thread switching prohibition factor is memory access.
  • FIG. 1 is a block diagram showing a configuration example of a multi-thread processor according to the present invention.
  • FIG. 2 is a flowchart showing a flow of a general thread switching process in the context switch unit according to the present invention.
  • FIG. 7 is a flowchart showing an example of the flow of thread switching processing in the context switch unit when the thread switching prohibition factor is the start of execution of a multicycle instruction.
  • FIG. 8 is a flowchart illustrating an example of thread switching processing in the context switch unit when the thread switching prohibition factor is acceptance of an interrupt or exception.
  • FIG. 9 is a block diagram of a processor board using a multi-thread processor according to the present invention.
  • FIG. 10 is a block diagram of a processor board using the multiprocessor system according to the present invention.
  • FIG. 11A is an explanatory diagram of thread switching processing according to a conventional example.
  • FIG. 11B is an explanatory diagram of thread switching processing according to the present invention.
  • the execution device 1 (refer to the multi-thread processor 10 and the multi-processor system 12) that is a multi-thread processor or a multi-processor system is, for example, the multi-thread processor 10 and can execute and execute a plurality of threads simultaneously.
  • a thread scheduling unit 105 that selects a first thread from one or more threads in a state and requests switching between the selected first thread and a second thread that is being executed by the execution device 1;
  • a context switch unit 104 that swaps the context of the second thread in the second thread and the context of the first thread in the executable state, and the context switch unit 104 receives the second request being executed after the switching request is made.
  • Thread 31 is thread If it is detected whether or not switching is possible, and if it is detected that the switching is impossible, the thread switching prohibiting factor is based on the thread switching prohibiting factor that caused the impossible state. Until it is released (see time 7S), it waits for a notice of thread switching acceptance to the thread scheduling unit 105, or notifies the thread scheduling unit 105 of a rescheduling request (see period 92). Determine whether.
  • the period 8 (FIG. 11B) is a relatively short period 8S (lower column in FIG. 11B) (see S16, S26, S35, S47 to S48, S55, etc.) ).
  • this specifying unit may be, for example, a part or the whole of the context switch unit 104.
  • the short period 8S is specified (see the lower column in FIG. 11B, No in S16, etc.), it can be executed at time 7 (time 7S in the lower column in FIG. 11B) when the period 8 ends.
  • Execution of the thread (thread C) in the state may be started by the instruction execution unit 109.
  • control unit that controls the instruction execution unit 109 to perform such an operation.
  • This control unit may be, for example, part or all of the context switch unit 104.
  • execution of the thread in the executable state is started at a time as late as time 7L (see time 66L in FIG. 11A), and processing delays are avoided. That is, the execution is started at an early time of time 72 in the upper column of FIG. 11B, the processing delay is avoided, and the processing can be performed at high speed.
  • FIG. 1 is a block diagram showing a configuration example of a multi-thread processor according to the present invention.
  • the multi-thread processor 10 includes a plurality of context units 100 (context units 100a and 100b), a context switch unit (context switch device) 104, a thread scheduling unit 105, an instruction fetch unit 107, and an instruction decode unit (decode unit). 108, instruction execution unit 109, interrupt control unit 113, level 1 instruction cache (level 1 instruction cache memory, instruction cache) 114, level 1 data cache (level 1 data cache memory, data cache) 116, level 2 cache 118.
  • the instruction execution unit 109 includes an FPU (Floating Point number processing Unit) 110, a load / store unit 112, an integer computing unit group 111, and the like.
  • FPU Floating Point number processing Unit
  • load / store unit 112 an integer computing unit group 111, and the like.
  • the level 1 instruction cache memory 114 and the level 1 data cache memory 116 each include an instruction TLB (Translation Lookaside Buffer) 115 and data TLB117.
  • instruction TLB Translation Lookaside Buffer
  • Each context unit 100 includes a program counter 101 that stores an address of an instruction to be read next, an instruction buffer 102 that stores the read instruction, and a register file 103 that stores an operation result.
  • the number of context units 100 is the same as the number of threads to be executed at the same time. In the example of FIG.
  • the thread scheduling unit 105 includes a context memory 106 for holding a thread context.
  • the thread scheduling unit 105 performs scheduling based on the priority order and execution order of a plurality of threads. In this scheduling, a thread to be executed next is selected from one or more threads in an executable state. In this scheduling, a thread to be returned to the next executable state is selected from one or more currently executing threads.
  • the thread scheduling unit 105 requests the context switch unit 104 to switch the threads of the two threads selected by the scheduling.
  • the thread scheduling unit 105 waits for a response from the context switch unit 104 after this thread switching request.
  • the waiting response is a thread switching acceptance notification or a rescheduling requesting that scheduling (see period 92) be performed again after scheduling (see period 91 in FIG. 11B) to which the thread switching request has been made. It is a request.
  • the context switching unit 104 returns a rescheduling request response, the thread scheduling unit 105 performs scheduling again.
  • the next switching is performed.
  • Request The switching is performed by the above-mentioned ready state thread selected in the previous scheduling and the in-execution state selected in the previous scheduling that has been selected again in the rescheduling and has resulted in the request for rescheduling. This is a switching to a thread that is running separately from the thread.
  • the thread scheduling unit 105 performs the next switching. Request.
  • the switch was made possible by the above-mentioned higher-priority thread, and the execution selected by the previous scheduling that resulted in the re-scheduling result that was selected again by rescheduling. This is a switch to a running thread different from the middle thread.
  • the context switch unit 104 performs the following confirmation in response to a thread switching request (described above) from the thread scheduling unit 105. In the confirmation, it is confirmed whether or not the thread being executed to be switched and selected in the previous scheduling is in a thread switching prohibition state. Then, the context switch unit 104 determines whether to actually perform thread switching.
  • the context switch unit 104 performs the following operation when performing thread switching.
  • the context of the context unit 100 of the executing thread selected in the previous scheduling of the switching target is saved in the context memory 106.
  • the context of the thread in the executable state selected in the previous scheduling that will be in the next execution state is returned from the context memory 106 that stores it to the context unit 100 that has been saved.
  • the thread scheduling unit 105 is notified of acceptance of thread switching.
  • the context switch unit 104 makes a rescheduling request to the thread scheduling unit 105 without performing such a context exchange or the like when the thread switching is not performed.
  • FIG. 2 is a flowchart showing a flow of general thread switching processing in the context switch unit 104.
  • the context switching unit 104 detects a thread switching request from the thread scheduling unit 105 (Yes in S11), the context switching unit 104 performs the following operation. In this operation, it is confirmed whether the thread being executed (thread 31 in FIG. 11B) selected by the previous scheduling to be switched is in a thread switching prohibition state (S12). If the executing thread to be switched is not in the thread switching prohibition state (No in S12), the following operation is performed. In the operation, the contents of the context unit 100 storing the context (context 119a) of the thread that is being switched are saved in the context memory 106. In this operation, the context return operation is performed for the thread in the executable state selected in the previous scheduling, which is in the next execution state (S13). In this return operation, as described above, the return operation from the context memory 106 to the saved context unit 100 is performed. In this operation, a thread switching acceptance notification is sent to the thread scheduling unit 105 (S14).
  • the context switch unit 104 identifies a thread switching prohibition factor (S15). .
  • the period of the thread switching prohibition state specified from the specified factor is compared with the scheduling period of the thread scheduling unit 105, and the two periods are evaluated (S16).
  • the above operation dynamically changes the thread switching operation according to the state of the processor. For this reason, after the previous scheduling by the thread scheduling unit 105 is completed, even if the thread being executed to be switched and selected in the previous scheduling is in the thread switching prohibition state, the process continues efficiently. Is done.
  • control register may be provided. That is, an operation performed when a thread switching request is received, context switching, an operation of waiting for notification of thread switching acceptance to the thread scheduling unit 105, and a thread rescheduling request to the thread scheduling unit 105 Which one of the two operations to be notified is not determined fixedly by hardware for each thread switching prohibition factor, but may be made variable by setting. Therefore, a control register that is set as described above may be provided so as to be variable.
  • the present invention can also be applied to a multiprocessor system.
  • FIG. 3 is a block diagram showing a configuration example of the multiprocessor system 12 according to the present invention.
  • the multiprocessor system 12 includes a plurality of processor cores 11 (11a, 11b), a thread scheduling unit 105, and a level 2 cache 118.
  • the thread scheduling unit 105 and the level 2 cache 118 include a plurality of levels. Shared among the other processor cores 11.
  • Each processor core 11 includes a context unit 100, a context switch unit 104, a thread scheduling unit 105, an instruction fetch unit 107, an instruction decoding unit 108, an instruction execution unit 109, an interrupt control unit 113, a level 1 An instruction cache 114 and a level 1 data cache 116 are provided.
  • each processor core 11 includes only one context unit 100.
  • each processor core 11 may include a plurality of context units 100 as in the multi-thread processor 10 (FIG. 1).
  • FIG. 4 is a flowchart illustrating an example of thread switching processing in the context switching unit 104 when the thread switching prohibition factor is memory access.
  • the selected running thread When there is a thread switching request from the thread scheduling unit 105, the selected running thread may be processing a memory access. For this reason, a thread switching process in the case where the selected running thread is in a thread switching prohibited state is shown.
  • the context switching unit 104 detects a thread switching request from the thread scheduling unit 105 (Yes in S21), the context switching unit 104 checks whether there is a memory access being processed in the selected thread that is being switched. (S22). When there is no memory access being processed in the executing thread to be switched, the following operation is performed. In the operation, a save operation to the context memory 106 is performed from the context unit 100 of the context of the thread that is being switched (S23). In this operation, the context of the thread to be executed next is returned from the context memory 106 to the context unit 100 (S23). In this operation, a thread switching acceptance notification is sent to the thread scheduling unit 105 (S24).
  • the context switch unit 104 performs the following operation when there is a memory access being processed in the thread being executed to be switched.
  • the state of the memory access being processed is specified by the access state information from each of the level 1 data cache 116 and the level 1 instruction cache 114 (S25).
  • the memory access states indicated and notified by the access state information from the level 1 data cache 116 include the following states. That is, there are states such as cache hit / cache miss in load access, cache hit / cache miss in store access, TLB miss, uncached load access, and uncached store access.
  • the memory access states indicated and notified by the access state information from the level 1 instruction cache 114 include the following states. That is, there are states such as cache hit / cache miss, TLB miss, and uncached instruction fetch in instruction fetch.
  • the context switch unit 104 evaluates the duration of the specified memory access state and the scheduling period of the thread scheduling device (thread scheduling unit) 105 (S26).
  • the duration of at least one of the access states of the level 1 data cache 116 or the level 1 instruction cache 114 specified as a result of the above evaluation is longer than the scheduling period of the thread scheduling device 105
  • the following operation is performed. In this operation, a rescheduling request is made to the thread scheduling unit 105 without saving the context of the currently executing thread and returning the context of the thread that is to be executed next (S27).
  • each memory access state continues varies depending on the implementation form of the level 1 data cache 116 and the level 1 instruction cache 114. Further, the period during which each memory access state continues also changes depending on whether the cache is hierarchized or the number of hierarchies up to the last level cache (level 2 cache 118 in FIG. 1 or 3).
  • the cache is hierarchized into two levels. Therefore, the following control register may be provided. That is, an operation performed when a thread switching request is received, a context replacement, an operation of waiting for a thread switching acceptance notification to the thread scheduling apparatus 105, and a thread rescheduling request to the thread scheduling apparatus 105. Which one of the two operations to be performed is not fixedly determined by hardware for each access state, but may be made variable by setting.
  • a control register that is set as described above may be provided so as to enable this.
  • the duration of the access state is very short.
  • the duration of the cache miss state is very short. That is, when the cache line can be secured, the level 1 data cache memory 116 can be implemented to complete the processing. For this reason, when such an implementation is implemented, the duration of the cache miss state in store access is very short.
  • the level 1 cache memories 114 and 116 can be implemented so that the processing is completed when a store command to the last level cache or the memory I / F block is issued. In this case, the duration of the uncached store state is very short.
  • TLB miss when a TLB miss occurs, it is possible for the hardware to read the page table on the memory and replace the TLB.
  • the hardware On the other hand, it is possible to adopt a method of notifying the OS of an interrupt, the software reading the page table, and replacing the contents of the TLB, and this method is increasingly used. In the latter case, since the processing is completed in the level 1 cache memories 114 and 116 when the interrupt is notified, the duration of the TLB miss state is very short.
  • the level 1 cache memories 114 and 116 cannot complete the processing until the load data can be received. For this reason, when a load access is performed, the state in which a cache miss has occurred or the duration of the uncached load access state is long and may be longer than the scheduling period of the thread scheduling device 105.
  • FIG. 5 is a flowchart showing an example of the thread switching process in the context switch unit 104 when the thread switching prohibiting factor is memory access.
  • the access state is a state in which an uncached load access is being executed, or a cache miss has occurred in the load access. There may be.
  • the thread switching process in the context switch unit 104 in this case is shown.
  • the context switch unit 104 performs the following confirmation when there is a memory access being processed in the thread being executed that is to be switched.
  • the state of the memory access being processed is determined as a cache miss state during load access or an uncached load based on access state information from each of the level 1 data cache 116 and the level 1 instruction cache 114. It is confirmed whether it is in the access state (S35).
  • the context switch unit 104 saves the context of the currently executing thread and executes it next.
  • a rescheduling request is made to the thread scheduling unit 105 without performing a return operation of the context of the thread that is in the state (S36).
  • the period during which each memory access state continues depends on whether the cache is hierarchical or not, and the number of layers up to the last level cache.
  • the caches are hierarchized, even if a cache miss occurs in the level 1 caches 114 and 116, if a cache hit occurs in the level 2 cache 118, the access can be completed in ten or more cycles.
  • the scheduling period of the thread scheduling device 105 may be longer than the duration of the memory access state.
  • FIG. 6 is a flowchart showing the flow of thread switching processing in the context switch unit 104 of the processor having the level 2 cache 118.
  • the context switch unit 104 performs the following confirmation when there is a memory access being processed in the thread being executed that is to be switched.
  • the confirmation it is confirmed from the access state information from each of the level 1 data cache 116 and the level 1 instruction cache 114 whether the state of the memory access being processed is an uncached load access state (S45). If the memory access being processed is not in the uncached load access state (No in S45), it is confirmed whether the cache access is in a load miss (S47). If the memory access state being processed is a cache miss state during load access (Yes in S47), the access state of the level 2 cache 118 is further referred to, and the level 2 cache 118 is in a cache hit state. It is confirmed whether there is a cache miss state (S48).
  • the context switch unit 104 When the access state is an uncached load access state (Yes in S45), the context switch unit 104 is a load access, a cache miss occurs in the level 1 data cache 116 (Yes in S47), but in the level 2 cache, In the case of a cache hit state (Yes in S48), the following operation is performed in any case. In the operation, the rescheduling request is made to the thread scheduling unit 105 without saving the context of the currently executing thread and returning the context of the thread that will be executed next (S46). In the case of other access states, the process returns to the confirmation of the thread switching prohibition state again (No in S47, No in S48).
  • FIG. 7 is a flowchart showing thread switching processing in the context switch unit 104 when the thread switching prohibition factor is during execution of a multi-cycle instruction.
  • the context switching unit 104 detects a thread switching request from the thread scheduling unit 105 (Yes in S51), the context switching unit 104 checks whether a multi-cycle instruction is started in the executing thread to be switched (S52). The context switch unit 104 performs the following operation when the multi-cycle instruction is not started in the executing thread to be switched (No in S52). In the operation, a save operation to the context memory 106 is performed from the context unit 100 of the context of the thread that is being switched. In the operation, the context of the next thread to be executed is returned from the context memory 106 to the context unit 100 (S53). In this operation, a thread switching acceptance notification is sent to the thread scheduling unit 105 (S54).
  • the context switch unit 104 performs the following operation when the execution of the multi-cycle instruction is started in the thread being executed to be switched (Yes in S52). In that operation, it is confirmed from the information from the instruction execution unit 109 whether the multi-cycle instruction that has been started is an integer division instruction or a floating-point convergence operation instruction (S55).
  • the context switch unit 104 checks the thread switching prohibition state again. Return.
  • the context switch unit 104 performs the following operation. In this operation, a rescheduling request is made to the thread scheduling unit 105 without saving the context of the currently executing thread and returning the context of the thread that will be executed next (S56).
  • the multicycle instruction to be detected need not be limited to an integer division instruction or a floating-point convergence operation instruction, and the following instruction may be detected. That is, the number of cycles until the execution of the instruction is completed is longer than the scheduling period of the thread scheduling unit 105. Such an instruction may be specified (detected).
  • FIG. 8 is a flowchart showing thread switching processing in the context switch unit 104 when the thread switching prohibition factor is an interrupt or an exception.
  • the context switching unit 104 When the context switching unit 104 detects a thread switching request from the thread scheduling unit 105 (Yes in S61), the context switching unit 104 checks whether an interrupt or an exception has occurred in the executing thread to be switched (S62).
  • the context switch unit 104 performs the following operation when an interrupt or exception has not occurred in the executing thread to be switched (No in S62).
  • a save operation from the context unit 100 of the context of the thread being executed to be switched to the context memory 106 is performed.
  • the context of the next thread to be executed is returned from the context memory 106 to the context unit 100 (S63).
  • a thread switching acceptance notification is sent to the thread scheduling unit 105 (S64).
  • the context switch unit 104 determines the type of interrupt or exception that has occurred, based on information from the interrupt control unit 113. Check (S65).
  • the context switch unit 104 checks the value of the thread switching control register corresponding to the specified interrupt or exception (S66).
  • the context switch unit 104 performs the following operation. In this operation, a rescheduling request is made to the thread scheduling unit 105 without saving the context of the currently executing thread and returning the context of the thread that will be executed next (S68).
  • the context switch unit 104 returns to the confirmation of the thread switching prohibition state again.
  • the processor switches to the supervisor state and executes an interrupt routine or an error handling program.
  • thread switching is generally prohibited.
  • the scheduling period of the thread scheduling unit 105 is determined by the implementation specifications of the thread scheduling unit 105, and the processing amount of the interrupt routine and the abnormal processing program varies depending on the type of interrupt or exception.
  • the processing amount of the interrupt routine and the abnormality processing program can be grasped by the creator of the interrupt routine. Therefore, the creator of these interrupt routines or the like can update the value of the thread switching control register at an appropriate location in the interrupt routine or abnormality processing program.
  • the context switching and the notification of thread switching acceptance to the thread scheduling unit 105 are performed.
  • the operation to be performed is switched to the operation for waiting.
  • FIG. 9 is a block diagram showing a basic configuration of the processor board 40 using the multi-thread processor according to the present invention.
  • the processor board 40 includes a system LSI 41 including the multi-thread processor 10 according to the present invention, an on-board memory 407, and connectors 408 and 409 for external devices.
  • the system LSI 41, the on-board memory 407, and the external devices The connectors 408 and 409 are connected by an on-board bus 406.
  • system LSI 41 includes a graphics engine 400, a codec engine 401, a stream IO (input-output) block 403, a memory IF (interface) block 404, and AVIO (Audio Visual Input Input Output).
  • Block 405 which are interconnected via an on-chip bus 402.
  • the graphics engine 400 performs a drawing process such as a GUI (Graphical User Interface) operation under the control of the multi-thread processor 10.
  • GUI Graphic User Interface
  • the codec engine 401 is controlled by the multi-thread processor 10 under the control of the H.264 codec.
  • H.264 and MPEG (Moving Picture Experts Group) video formats, and audio formats such as DTS (Digital Theater Systems) and AAC (Advanced Audio Coding) are decoded and encoded.
  • DTS Digital Theater Systems
  • AAC Advanced Audio Coding
  • the memory IF block 404 controls the next data request under the control of the multi-thread processor 10.
  • the data request to be controlled is a request such as data transfer to / from the graphics engine 400, codec engine 401, stream IO block 403, AVIO block 405, and on-board memory 407 via the on-chip bus 402. It is.
  • the stream IO block 403 reads stream data such as a compressed video / audio stream from storage media and peripheral devices such as a network under the control of the multi-thread processor 10.
  • the stream IO block 403 stores the read stream data in the on-board memory 407 via the memory IF block 404 and the on-chip bus 402, and transfers the stream data in the opposite direction.
  • the AVIO block 403 reads image data, audio data, and the like from the on-board memory 407 via the memory IF block 404 and the on-chip bus 402 under the control of the multi-thread processor 10.
  • the AVIO block 403 transfers the read image data and the like to the codec engine 401 and the graphics engine 400, and transfers the image data and the like in the opposite direction.
  • FIG. 10 is a block diagram showing a basic configuration of the processor board 42 using the multiprocessor system according to the present invention.
  • the processor board 42 includes a system LSI 42 including the multiprocessor system 12 according to the present invention, an on-board memory 407, and connectors 408 and 409 for external devices.
  • the system LSI 42, the on-board memory 407, and the external devices The connectors 408 and 409 are connected by an on-board bus 406.
  • system LSI 42 includes a graphics engine 400, a codec engine 401, a stream IO block 403, a memory IF block 404, and an AVIO block 405. These include an on-chip bus 402. Are connected to each other.
  • the cause of thread switching prohibition is a factor caused by execution of a multi-cycle instruction or a factor caused by a cache memory built in the processor such as the level 1 data cache 116.
  • the order of the thread switching prohibition period is an order of several cycles to several tens of cycles.
  • the cause of thread switching prohibition is a cause caused by access to the on-board memory 407, such as uncached memory access or a cache miss of the last level cache built in the multi-thread processor 10.
  • the order of the switching prohibition period is an order of several hundred cycles.
  • the thread scheduling unit 105 After the thread scheduling unit 105 completes scheduling (refer to the period 91), the state of the execution target thread (thread 31) to be switched is in a thread switching prohibition state due to access to the on-board memory 407. There are cases (see period 8L). Even in this case, in the processor boards 40 and 42, the context switch unit 104 switches the operation to be dynamically performed to the operation for performing the rescheduling process (see period 92) in the thread scheduling unit 105 (upper column in FIG. 11B). )be able to.
  • processing of the second thread may be executed.
  • the thread to be executed may be switched from the second thread before switching to the first thread after switching (see the thread 33 in FIGS. 11A and 11B).
  • the time at which the execution of the first thread is started may be a time after the time (see 7S) at which the period 8 until the execution of the second thread ends (completely) ends.
  • the time when the execution of the first thread is started may be the same as the end time described above.
  • the period 8 includes not only a relatively short period 8S (lower column in FIG. 11B) but also a relatively long period 8L (upper column in FIG. 11B, FIG. 11A).
  • the memory is accessed during the period 8, and this period 8 is not the relatively short period 8S but the relatively long period 8L. is there.
  • FIG. 11A the situation shown in FIG. 11A is assumed in technologies other than the present technology. That is, in the technique of FIG. 11A, the execution of the first thread (thread 33) is started at time 6L when the relatively long period 8L ends. Therefore, in FIG. 11A, this time is significantly later than the start time 72 of the thread 33 in the upper column of FIG. 11B, and processing delay occurs.
  • the long period 8L refers to, for example, a period in which the processing delay is long enough to cause an adverse effect.
  • the period 8 is a relatively short period 8S (lower column in FIG. 11B) (S16, S26, S35, S47 to S48, S55, etc.) reference).
  • the execution of the first thread may be started (see S17 and the like).
  • time 72 starts at time 72 (see time 62 in FIG. 11A) in the upper column of FIG. 11B and starts at an earlier time, avoiding a delay in processing, and enabling high-speed processing.
  • the present invention can be realized not only as a device, a system, and an integrated circuit, but also as a method using a processing unit that constitutes the device as a step or in other categories. It is also possible.
  • the multithread processor and the multiprocessor system As described above, in the multithread processor and the multiprocessor system according to the present technology, when thread switching is started after thread scheduling (see period 91) is completed, a thread to be switched (thread 31) to be switched is started. However, even when the thread switching is prohibited (see period 8), an appropriate operation is performed. That is, in that case, the processing efficiency can be increased by dynamically changing the thread switching operation (see the period 92 or the like) according to the state of the processor (see the periods 8S and 8L).
  • the present technology has such an effect and is useful for a processor board mounted on a multi-thread processor, a multi-processor system, and a digital television, a DVD recorder, a mobile phone device, or the like using one or both of them. is there.

Landscapes

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

Abstract

 マルチスレッドプロセッサ(10)は、実行可能状態となった第1のスレッドと、実行中の第2のスレッドとの切り替えを要求するスレッドスケジューリング部(105)と、第2のスレッドと、第1のスレッドのコンテキストを入れ替え、要求がされた後に、第2のスレッドが、切り替えが不能な状態となっているか否かを検出し、なっていることが検出された場合、その状態を生じさせた要因に基づいて、待機するか、再スケジューリング要求をするかを判定するコンテキストスイッチ部(104)とを備える。

Description

マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード
 本発明は、複数のスレッドを並列に実行するマルチスレッドプロセッサや、複数のプロセッサコアを有するマルチプロセッサシステムに関し、特に、スレッド切り替え装置に関する。
 プロセッサの処理性能を向上させるために、以下の各アーキテクチャ機構が考案されてきた。つまり、スーパースカラによる並列実行、Out-of-Order実行等の、IPC(Instruction Per Cycle)を向上させるアーキテクチャ機構が考案されてきた。また、ディープパイプラインといった、動作周波数を向上させるアーキテクチャ機構が考案されてきた。
 しかし、これらの、プロセッサ単体での性能向上は限界に達しつつあり、投資する回路規模や、増加する消費電力に見合う性能向上が得られなくなっている。
 そのため、近年、複数のスレッド(もしくはプロセス)を1つのプロセッサ上で同時に実行可能なマルチスレッドプロセッサや、複数のスレッドを別個のプロセッサで並列に実行するマルチプロセッサが注目を集めている。
 本明細書においては、各スレッドが使用する、レジスタやプログラムカウンタ等の情報を、コンテキストと呼ぶ。
 マルチスレッドプロセッサには、スレッド毎のコンテキストを保存するための複数のコンテキストユニットが実装される。マルチスレッドプロセッサは、コンテキストユニット毎にスレッドを割り当て、複数のスレッドを同時に実行する。
 マルチプロセッサでは、プロセッサコア毎にスレッドを割り当て、複数のスレッドを同時に実行する。
 これら、マルチスレッドプロセッサやマルチプロセッサシステムでは、コンテキストユニットに割り当てられていない、待機状態のスレッドがある。このような待機状態のスレッドの1つ以上のうちから、次に実行する、待機状態のスレッドを選択する。また、これらマルチスレッドプロセッサ等では、コンテキストユニットに割り当てられている実行中のスレッドもある。このような実行中のスレッドの複数個のうちからから、次に待機状態となる、実行中のスレッドを選択する。そして、選択された、これらの2つのスレッドを切り替える。
 このようなスレッド切り替えでは、次の動作がされる。その動作では、コンテキストユニットから、そのコンテキストユニットにより記憶される、選択された、切り替え対象の実行中のスレッドのコンテキストを退避する。そして、その動作では、選択された、次に実行する、待機状態のスレッドのコンテキストを、上述の退避がされた後のコンテキストユニットに復帰させる。コンテキストの退避が完了した、切り替え対象の実行中のスレッドは、待機状態となる。また、コンテキストユニットへの復帰が完了した、切り替え対象の待機状態のスレッドは、実行状態となり、そのスレッドの実行が再開される。本明細書においては、このような、切り替え対象となる2つのスレッドの選択を、スケジューリングと呼ぶ。特許文献1や特許文献2では、マルチスレッドプロセッサや、マルチプロセッサシステムにおいて、処理効率を上げるために、スケジューリングにおいて、次のことがされる。そのこととは、プロセスに固有な優先度だけではなく、スレッドの過去の実行履歴や、プロセッサの実行状態を加味した優先度に基づき、切り替え対象となるスレッドの選択を行うことである。
特開2010-205046号公報 特許第4086846号公報
マイクロプロセッサ・アーキテクチャ入門 2004年 CQ出版社 プロセッサを支える技術 2011年 技術評論社
 マルチスレッドプロセッサやマルチプロセッサシステムにおいて、スレッド切り替えが完結するためには、次の処理をする必要がある。その処理は、選択された、次に待機状態となる、コンテキストユニットに割り当てられている実行中のスレッドに関する。つまり、その実行中のスレッドが、命令の実行を安全に停止した後に、そのスレッドのコンテキストを退避する必要がある。スレッドのスケジューリングを完了し、スレッド切り替えを開始した時には、選択された、切り替え対象の実行中のスレッドの処理が、パイプラインに存在し、残存している。この残存している処理が、処理途中の未完了のメモリアクセスであった場合や、割り込みまたは例外の処理であった場合には、スレッド切り替えを行うことができないことがある。
 しかしながら、特許文献1や特許文献2では、スケジューリングを行う際にしか、プロセッサの実行状態を参照していない。このため、これら特許文献1等では、次の課題がある。つまり、スレッド切り替えを開始した時に、選択された、切り替え対象の実行中のスレッドの状態が、未完了のメモリアクセスや、割り込みまたは例外の処理により、スレッド切り替えを行うことができないスレッド切り替え禁止状態である場合がある。この場合に、スケジューリングにより選択した、待機状態のスレッドの実行を開始することができず、処理の効率が下がってしまうという課題がある。
 なお、後述の図11Aに示すように、スレッド切り替え禁止状態の期間(期間8Lを参照)が、スレッドのスケジューリングに要する期間(期間92などを参照)より長い場合(図2のS16など参照)がある。この場合には、特に、処理の効率が下がることになる。
 そこで、本発明は、処理の効率がより高いマルチスレッドプロセッサ等を提供することを目的とする。
 上記の課題を解決するために、本発明に係る実行装置(マルチスレッドプロセッサおよびマルチプロセッサシステムの何れか)は、第1、第2のスレッドを実行し、実行可能状態となった1以上のスレッドから前記第1のスレッドを選択し、選択された前記第1のスレッドと、実行中の前記第2のスレッドとの切り替えを要求するスレッドスケジューリング装置と、実行中の前記第2のスレッドのコンテキストと、実行可能状態の前記第1のスレッドのコンテキストとを入れ替えるコンテキストスイッチ装置とを備え、前記コンテキストスイッチ装置は、前記切り替えの要求がされた後に、実行中の前記第2のスレッドが、スレッドの切り替えが不能な状態となっているか否かを検出し、前記不能な状態となっていることが検出された場合、前記不能な状態を生じさせたスレッド切り替え禁止要因に基づいて、前記スレッド切り替え禁止要因が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、前記スレッドスケジューリング装置へ、再スケジューリング要求を通知するかを判定する。
 例えば、本発明に係るマルチスレッドプロセッサおよびマルチプロセッサシステムでは、実行可能状態となったスレッドから少なくとも1つのスレッドを選択し実行中のスレッドとの切り替えを指示するスレッドスケジューリング装置と、実行中のスレッドのコンテキストと実行可能状態のスレッドのコンテキストを入れ替えるコンテキストスイッチ装置を備えており、前記スレッドスケジューリング装置からスレッド切り替え要求が出力された後、前記コンテキストスイッチ装置において、切り替え対象の実行中のスレッドがスレッドを切り替えられない状態となっていることが検出された場合、前記コンテキストスイッチ装置は、スレッド切り替え禁止要因が解除されるまでコンテキストの入れ替えおよび前記スレッドスケジューリング装置へのスレッド切り替え受理の通知を待機するか、スレッドスケジューリング装置へ再スケジューリング要求を通知するかをスレッド切り替え禁止の要因によって判定することを特徴とする。
 また、前記スレッドスケジューリング装置は、前記スレッドスイッチ装置からスレッドの再スケジューリングを要求された場合、スレッド切り替えを要求していたスレッドより優先度の高いスレッドが新たに実行可能状態になっていなければ、再スケジューリングを要求されたスレッドとは別の実行中のスレッドとの切り替えを要求し、スレッド切り替えを要求していたスレッドより優先度の高いスレッドが新たに実行可能状態になっていた場合は、より優先度の高いスレッドと、再スケジューリングを要求されたスレッドとは別の実行中のスレッドとの切り替えを要求することを特徴とする。
 これらの構成により、図11Bに示すように、スレッド切り替え禁止状態の期間(図11Bの期間8を参照)が、スレッドのスケジューリングに要する期間(図11Bの期間92を参照)より長い場合には(図11B上段の期間8Lを参照)、スレッド切り替え禁止状態ではない他の実行中のスレッド(スレッド32を参照)を、切り替え対象として、すばやく選択し直す。このことで、処理の効率が上がる(時刻72を参照)。また、スレッド切り替え禁止状態の期間が、スレッドのスケジューリングに要する期間より短い場合には(下段の期間8Sを参照)、再スケジューリング(期間92を参照)によるオーバヘッドを受けないため、処理の効率が上がる。これにより、何れの場合にも、高い効率での処理ができる。
 本発明によれば、スレッドのスケジューリング完了後、スレッド切り替えを開始した時に、切り替え対象の実行中のスレッドが、スレッド切り替え禁止状態となっていた場合でも、プロセッサの状態に応じて、動的に、スレッド切り替えの動作を変更することにより、処理の効率を上げることができる。
 また、行われる処理が、より高速にできる。
図1は、本発明に係るマルチスレッドプロセッサの構成例を示すブロック図である。 図2は、本発明に係るコンテキストスイッチ部における一般的なスレッド切り替え処理の流れを示すフローチャートである。 図3は、本発明に係るマルチプロセッサシステムの構成例を示すブロック図である。 図4は、スレッド切り替え禁止要因がメモリアクセスである場合の、コンテキストスイッチ部におけるスレッド切り替え処理の一例を示すフローチャートである。 図5は、スレッド切り替え禁止要因がメモリアクセスである場合の、コンテキストスイッチ部におけるスレッド切り替え処理の一例を示すフローチャートである。 図6は、スレッド切り替え禁止要因がメモリアクセスである場合の、コンテキストスイッチ部におけるスレッド切り替え処理の一例を示すフローチャートである。 図7は、スレッド切り替え禁止要因がマルチサイクル命令の実行開始である場合の、コンテキストスイッチ部におけるスレッド切り替え処理の流れの一例を示すフローチャートである。 図8は、スレッド切り替え禁止要因が割り込みもしくは例外の受理である場合の、コンテキストスイッチ部におけるスレッド切り替え処理の一例を示すフローチャートである。 図9は、本発明に係るマルチスレッドプロセッサを用いたプロセッサボードのブロック図である。 図10は、本発明に係るマルチプロセッサシステムを用いたプロセッサボードのブロック図である。 図11Aは、従来例によるスレッド切り替え処理の説明図である。 図11Bは、本発明に係るスレッド切り替え処理の説明図である。
 以下、本発明の実施の形態について図面を参照して詳しく説明する。なお、図面において、同一または相当する部分には、同一の参照符号を付してその説明は繰り返さない。なお、以下で説明する実施の形態は、何れも本発明の好ましい一具体例を示すものである。以下の実施の形態で示される数値、形状、材料、構成要素、構成要素の配置位置及び接続形態、ステップ、ステップの順序等は、一例である。よって、以下の実施の形態における構成要素のうち、本発明の最上位概念を示す独立請求項に記載されていない構成要素については、本発明の課題を達成するのに必ずしも必要ではないが、より好ましい形態を構成するものとして説明される。
 実施形態において、マルチスレッドプロセッサまたはマルチプロセッサシステムである実行装置1(マルチスレッドプロセッサ10、マルチプロセッサシステム12を参照)は、例えばマルチスレッドプロセッサ10であり、複数のスレッドを同時に実行可能で、実行可能状態となった1以上のスレッドから第1のスレッドを選択し、選択された第1のスレッドと、実行装置1で実行中の第2のスレッドとの切り替えを要求するスレッドスケジューリング部105と、実行中の第2のスレッドのコンテキストと、実行可能状態の第1のスレッドのコンテキストとを入れ替えるコンテキストスイッチ部104とを備え、コンテキストスイッチ部104は、切り換えの要求がされた後に、実行中の第2のスレッド(スレッド31)が、スレッドの切り替えが不能な状態となっているか否かを検出し、不能な状態となっていることが検出された場合、不能な状態を生じさせたスレッド切り替え禁止要因に基づいて、前記スレッド切り替え禁止要因が解除されるまで(時刻7S参照)、コンテキストの入れ替え、および、スレッドスケジューリング部105への、スレッド切り替え受理の通知を待機するか、スレッドスケジューリング部105へ、再スケジューリング要求(期間92参照)を通知するかを判定する。
 すなわち、例えば、期間8(図11B)が、比較的短い期間8S(図11Bの下欄)であるか否かが特定されてもよい(S16、 S26、 S35、 S47~S48、 S55などを参照)。なお、この特定を行う特定部があってもよい。この特定部は、例えば、コンテキストスイッチ部104の一部または全体などでもよい。
 そして、短い期間8Sであるのが特定される場合にのみ(図11Bの下欄、S16のNoなど参照)、期間8が終了する時刻7(図11Bの下欄の時刻7S)に、実行可能状態のスレッド(スレッドC)の実行が、命令実行部109により開始されてもよい。
 そして、短い期間8Sではなく、長い期間8Lであるのが特定される場合には(図11Bの上欄、S16のYesなどを参照)、その期間8の間における時刻72(図11Bの上欄)において、実行可能状態のスレッド(スレッドD)の実行が開始されてもよい(S17などを参照)。
 なお、このような動作を命令実行部109にさせる制御をする制御部があってもよい。この制御部は、例えば、コンテキストスイッチ部104の一部または全体などでもよい。
 これにより、実行可能状態のスレッドが、時刻7L(図11Aの時刻66Lを参照)という遅い時刻に実行開始され、処理の遅延が生じてしまうのが回避される。つまり、図11Bの上欄の時刻72という早い時刻に実行開始がされ、処理の遅延が回避され、処理が高速にできる。
 図1は、本発明に係るマルチスレッドプロセッサの構成例を示すブロック図である。
 マルチスレッドプロセッサ10は、複数のコンテキスト部100(コンテキスト部100a、100b)と、コンテキストスイッチ部(コンテキストスイッチ装置)104と、スレッドスケジューリング部105と、命令フェッチ部107と、命令デコード部(デコード部)108と、命令実行部109と、割り込み制御部113と、レベル1命令キャッシュ(レベル1命令キャッシュメモリ、命令キャッシュ)114と、レベル1データキャッシュ(レベル1データキャッシュメモリ、データキャッシュ)116と、レベル2キャッシュ118とを備える。
 命令実行部109は、FPU(Floating Point number processing Unit)110や、ロード/ストアユニット112や、整数演算器群111等を備える。
 レベル1命令キャッシュメモリ114と、レベル1データキャッシュメモリ116とは、それぞれ、命令TLB(Translation Lookaside Buffer)115と、データTLB117とを備える。
 それぞれのコンテキスト部100は、次に読み出すべき命令のアドレスを格納するプログラムカウンタ101と、読み出された命令を格納する命令バッファ102と、演算結果を格納するレジスタファイル103とを備える。コンテキスト部100は、同時に実行するスレッド数と同数だけ実装されるが、図1の例では、説明の簡単のため、コンテキスト部100は2つとする。
 スレッドスケジューリング部105は、スレッドのコンテキストを保持するためのコンテキストメモリ106を備える。
 また、スレッドスケジューリング部105は、複数のスレッドの優先順位や実行順序に基づいて、スケジューリングを行う。このスケジューリングでは、実行可能状態の1以上のスレッドから、次に実行するスレッドを選択する。また、このスケジューリングでは、現在実行中の1以上のスレッドから、次に実行可能状態に戻すスレッドを選択する。スレッドスケジューリング部105は、このようなスケジューリングで選択された上述の2つのスレッドについて、コンテキストスイッチ部104に対し、それらの2つのスレッドのスレッド切り替え要求を行う。
 そして、スレッドスケジューリング部105は、このスレッド切り替え要求の後には、コンテキストスイッチ部104からの応答を待つ。待たれる応答は、スレッド切り替え受理通知、もしくは、そのスレッド切り替え要求がされた先のスケジューリング(図11Bの期間91を参照)よりも後に再びスケジューリング(期間92を参照)を行うことを要求する再スケジューリング要求である。スレッドスケジューリング部105は、コンテキストスイッチ部104から、再スケジューリング要求の応答が返ってきたら、再度、スケジューリングを行う。
 そして、上述の再スケジューリングでは、もともと、先のスケジューリングで、スレッド切り替えを要求していた実行可能状態のスレッドより優先度の高いスレッドが、新たに実行可能状態になっていなければ、次の切り替えを要求する。その切り替えは、先のスケジューリングで選択された上述の実行可能状態のスレッドと、再スケジューリングで選択し直した、再スケジューリングが要求される結果を生んだ上述の先のスケジューリングで選択された実行中のスレッドとは別の、実行中のスレッドとの切り替えである。
 一方で、スレッドスケジューリング部105は、先のスケジューリングで、スレッド切り替えを要求していた実行可能状態のスレッドより優先度の高いスレッドが、新たに実行可能状態になっていた場合には、次の切り替えを要求する。その切り替えは、実行可能状態になっていた、より優先度の高い上述のスレッドと、再スケジューリングで選択し直した、再スケジューリングを要求される結果を生んだ上述の先のスケジューリングで選択された実行中のスレッドとは別の実行中のスレッドとの切り替えである。
 コンテキストスイッチ部104は、スレッドスケジューリング部105からのスレッド切り替え要求(上述)に応じて、次の確認をする。その確認では、先のスケジューリングで選択された、切り替え対象の実行中のスレッドが、スレッド切り替え禁止状態であるかを確認する。そして、コンテキストスイッチ部104は、実際に、スレッド切り替えを行うかを決定する。
 コンテキストスイッチ部104は、スレッド切り替えを行う場合には、次の動作をする。その動作では、切り替え対象の方の、先のスケジューリングで選択された実行中のスレッドのコンテキスト部100のコンテキストを、コンテキストメモリ106へと退避する。また、その動作では、次に実行状態となる、先のスケジューリングで選択された実行可能状態のスレッドのコンテキストを、それを記憶するコンテキストメモリ106から、退避がされた上述のコンテキスト部100へ復帰する。また、その動作では、スレッドスケジューリング部105へ、スレッド切り替えの受理を通知する。
 なお、コンテキストスイッチ部104は、スレッド切り替えを行わない場合には、このような、コンテキストの入れ替え等を行わず、スレッドスケジューリング部105に、再スケジューリングの要求を行う。
 図2は、コンテキストスイッチ部104における、一般的なスレッド切り替え処理の流れを示すフローチャートである。
 コンテキストスイッチ部104は、スレッドスケジューリング部105からのスレッド切り替え要求を検出した場合(S11のYes)、次の動作をする。その動作では、切り替え対象の、先のスケジューリングで選択された実行中のスレッド(図11Bのスレッド31)が、スレッド切り替え禁止状態になっているかを確認する(S12)。切り替え対象の、実行中のスレッドが、スレッド切り替え禁止状態になっていなかった場合には(S12のNo)、次の動作をする。その動作では、切り替え対象の、実行中のスレッドのコンテキスト(コンテキスト119a)が格納されているコンテキスト部100の内容の、コンテキストメモリ106への退避をする。また、その動作では、次に実行状態となる、先のスケジューリングで選択された実行可能状態のスレッドのコンテキストの復帰操作をする(S13)。この復帰操作では、先述の通り、コンテキストメモリ106から、退避がされたコンテキスト部100への復帰操作を行う。また、その動作では、スレッドスケジューリング部105へ、スレッド切り替え受理通知を行う(S14)。
 一方、コンテキストスイッチ部104は、先のスケジューリングで選択された、切り替え対象の実行中のスレッドが、スレッド切り替え禁止状態であった場合(S12のYes)、スレッド切り替え禁止要因の特定を行う(S15)。
 そして、特定された要因から特定される、スレッド切り替え禁止状態の期間と、スレッドスケジューリング部105のスケジューリング期間とを比較して、それらの2つの期間の評価を行う(S16)。
 そして、この評価の結果、特定された全ての要因で、その要因での、スレッド切り替え禁止状態の期間の方が、より短いと推定される場合には(S16のNo)、再度、スレッド切り替え禁止状態の確認に戻る。もしくは、特定された禁止要因がなくなるまで、コンテキスト部100とコンテキストメモリ106とへの操作と、スレッドスケジューリング部105への、スレッド切り替え完了通知や、再スケジューリング要求の応答とをマスクするようにしても良い。
 一方、上述の評価の結果、特定された要因のうち1つでも、その要因での、スレッド切り替え禁止状態の期間の方が、スレッドスケジューリング部105のスケジューリング期間より長いと推定される場合には(S16のYes)、次の動作をする。その動作では、先のスケジューリングで選択された実行中のスレッドのコンテキストの退避と、次に実行状態となる、先のスケジューリングで選択された実行可能状態のスレッドのコンテキストの復帰操作(上述)を行わない。その動作では、スレッドスケジューリング部105に、再スケジューリング要求を行う(S17)。
 上記の操作により、プロセッサの状態に応じて、動的に、スレッド切り替えの動作を変更される。そのため、スレッドスケジューリング部105による先のスケジューリングが完了した後に、その先のスケジューリングで選択された、切り替え対象の実行中のスレッドが、スレッド切り替え禁止状態となっていた場合でも、効率よく、処理が継続される。
 なお、スレッド切り替え禁止状態が継続する期間の長さは、レベル1命令キャッシュ114や、レベル1データキャッシュ116や、命令実行部109の実装形態によって決定される。そのため、次の制御レジスタが設けられてもよい。つまり、スレッド切り替え要求を受け取った時にされる動作である、コンテキストの入れ替え、および、スレッドスケジューリング部105への、スレッド切り替え受理の通知を待機する動作と、スレッドスケジューリング部105へ、スレッドの再スケジューリング要求を通知する動作との2つの動作のうちのいずれの動作を行うかが、スレッド切り替え禁止要因毎に、ハードウェアで固定的に決まっているのではなく、設定によって、可変とされてもよい。そこで、可変とすることができるように、上述の設定がされる制御レジスタを設けてもよい。
 本発明は、マルチプロセッサシステムにも適用することができる。
 図3は、本発明に係るマルチプロセッサシステム12の構成例を示すブロック図である。
 本発明に係るマルチプロセッサシステム12は、複数のプロセッサコア11(11a、11b)と、スレッドスケジューリング部105と、レベル2キャッシュ118とを備え、スレッドスケジューリング部105と、レベル2キャッシュ118とは、複数のプロセッサコア11の間で共有される。
 それぞれのプロセッサコア11は、コンテキスト部100と、コンテキストスイッチ部104と、スレッドスケジューリング部105と、命令フェッチ部107と、命令デコード部108と、命令実行部109と、割り込み制御部113と、レベル1命令キャッシュ114と、レベル1データキャッシュ116を備えている。
 図3の例では、それぞれのプロセッサコア11は、コンテキスト部100を1つしか備えていない。一方、それぞれのプロセッサコア11は、マルチスレッドプロセッサ10(図1)のように、複数のコンテキスト部100を備えても良い。
 図4は、コンテキストスイッチ部104における、スレッド切り替え禁止要因がメモリアクセスである場合の、スレッド切り替え処理の一例を示すフローチャートである。
 スレッドスケジューリング部105からスレッド切り替え要求があった時に、選択された実行中のスレッドは、メモリアクセスを処理中であることがある。このために、選択された実行中のスレッドが、スレッド切り替え禁止状態となっている場合のスレッド切り替え処理が示される。
 コンテキストスイッチ部104は、スレッドスケジューリング部105からのスレッド切り替え要求を検出した場合(S21のYes)、選択された、切り替え対象の実行中のスレッドにおいて、処理中のメモリアクセスが存在しているかを確認する(S22)。切り替え対象の実行中のスレッドで、処理中のメモリアクセスが存在しなかった場合には、次の動作をする。その動作では、切り替え対象の実行中のスレッドのコンテキストのコンテキスト部100から、コンテキストメモリ106への退避操作を行う(S23)。また、その動作では、次に実行状態となるスレッドのコンテキストの、コンテキストメモリ106から、コンテキスト部100への復帰操作を行う(S23)。また、その動作では、スレッドスケジューリング部105へ、スレッド切り替え受理通知を行う(S24)。
 コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、処理中のメモリアクセスが存在した場合、次の動作をする。その動作では、レベル1データキャッシュ116と、レベル1命令キャッシュ114とのうちのそれぞれからのアクセス状態情報により、処理中のメモリアクセスの状態を特定する(S25)。
 レベル1データキャッシュ116からのアクセス状態情報により示されて通知される、メモリアクセスの状態には、次の各状態がある。つまり、ロードアクセスでのキャッシュヒット/キャッシュミス、ストアアクセスでのキャッシュヒット/キャッシュミス、TLBミス、アンキャッシュロードアクセス、アンキャッシュストアアクセスなどの状態がある。
 レベル1命令キャッシュ114からのアクセス状態情報により示されて通知される、メモリアクセスの状態には、次の各状態がある。つまり、命令フェッチでのキャッシュヒット/キャッシュミス、TLBミス、アンキャッシュ命令フェッチなどの状態がある。
 コンテキストスイッチ部104は、特定されたメモリアクセス状態の継続期間と、スレッドスケジューリング装置(スレッドスケジューリング部)105のスケジューリング期間との評価を行う(S26)。
 そして、この評価の結果、レベル1データキャッシュ116と、レベル1命令キャッシュ114のアクセス状態の継続期間が、共に、スケジューリング期間より短いと推定される場合には(S26のNo)、再度、スレッド切り替え禁止状態の確認に戻る。もしくは、処理中のメモリアクセスが完了するまで、コンテキスト部100とコンテキストメモリ106とへの操作と、スレッドスケジューリング装置105への、スレッド切り替え完了通知や、再スケジューリング要求の応答(先述)をマスクするようにしても良い。
 一方、上述の評価の結果、特定された、レベル1データキャッシュ116、もしくは、レベル1命令キャッシュ114のうちの何れか少なくとも1つのアクセス状態の継続期間が、スレッドスケジューリング装置105のスケジューリング期間より長いと推定される場合には(S26のYes)、次の動作がされる。その動作では、実行中のスレッドのコンテキストの退避と、次に実行状態となるスレッドのコンテキストの復帰操作とを行わず、スレッドスケジューリング部105に、再スケジューリング要求を行う(S27)。
 上記の操作により、スレッドスケジューリング部105の先のスケジューリングが完了した後に、切り替え対象の実行中のスレッドが、メモリアクセスを処理中であったために、スレッド切り替え禁止状態となっていた場合でも、効率よく、処理が継続される。
 なお、各メモリアクセスの状態が継続する期間は、レベル1データキャッシュ116や、レベル1命令キャッシュ114の実装形態によって変化する。また、キャッシュが階層化されているかどうかや、ラストレベルキャッシュ(図1または図3ではレベル2キャッシュ118)までの階層数によっても、各メモリアクセスの状態が継続する期間は変化する。図1のマルチスレッドプロセッサや、図3のマルチプロセッサシステムでは、キャッシュが、2レベルに階層化されている例を示している。そこで、次の制御レジスタが設けられてもよい。つまり、スレッド切り替え要求を受け取った時にされる動作である、コンテキストの入れ替え、および、スレッドスケジューリング装置105への、スレッド切り替え受理の通知を待機する動作と、スレッドスケジューリング装置105へ、スレッドの再スケジューリング要求を通知する動作との、2つの動作のうちのいずれの動作を行うかが、アクセス状態毎に、ハードウェアで固定的に決まっているのではなく、設定によって、可変とされてもよい。このことができるように、上述の設定がされる制御レジスタを設けてもよい。
 一般に、キャッシャブル領域へのアクセスで、レベル1データキャッシュ116やレベル1命令キャッシュ114でキャッシュヒットした場合、数サイクルで、アクセスは完了する。このため、この場合には、アクセス状態の継続期間は、非常に短い。
 キャッシャブル領域へのストアアクセスの場合、キャッシュミスが発生しても、レベル1データキャッシュ116が、ライトバック方式を採用していた場合では、キャッシュミス状態の継続期間は、非常に短い。つまり、キャッシュラインの確保ができた時点で、レベル1データキャッシュメモリ116では、処理を完了とする実装が可能である。このため、このような実装がされる場合には、ストアアクセスでの、キャッシュミス状態の継続期間は、非常に短い。
 アンキャッシュストアの場合、ラストレベルキャッシュまたはメモリI/Fブロックへのストアコマンドを発行した時点で、レベル1キャッシュメモリ114、116では、処理が完了する実装が可能である。この場合、アンキャッシュストア状態の継続期間は非常に短い。
 また、TLBミスが発生した場合、ハードウェアが、メモリ上のページテーブルを読んで、TLBを入れ替える方式を採ることが可能である。一方、OSに割り込みを通知し、ソフトウェアがページテーブルを読み、TLBの内容を入れ替えるという方式を採ることも可能であり、こちらの方式を採る場合が多くなってきている。後者の場合のプロセッサでは、割り込みを通知した時点で、レベル1キャッシュメモリ114、116では、処理が完了するため、TLBミス状態の継続期間は、非常に短い。
 これらの場合に対し、ロードアクセスがされる場合では、ロードデータの受理が出来るまで、レベル1キャッシュメモリ114、116は、処理を完了することが出来ない。このため、ロードアクセスがされる場合では、キャッシュミスが発生した状態や、アンキャッシュロードアクセス状態の継続期間は長いものとなり、スレッドスケジューリング装置105のスケジューリング期間よりも長くなる場合がある。
 図5は、コンテキストスイッチ部104における、スレッド切り替え禁止要因がメモリアクセスである場合の、スレッド切り替え処理の一例を示すフローチャートである。
 スレッド切り替え要求を受け取った時に、スレッドスケジューリング装置105へ再スケジューリング要求を通知する際において、アクセス状態が、アンキャッシュのロードアクセスを実行中の状態か、ロードアクセスでキャッシュミスが発生している状態である場合がある。この場合の、コンテキストスイッチ部104におけるスレッド切り替え処理が示される。
 コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、処理中のメモリアクセスが存在した場合、次の確認をする。その確認では、レベル1データキャッシュ116と、レベル1命令キャッシュ114とのうちのそれぞれからのアクセス状態情報により、処理中のメモリアクセスの状態が、ロードアクセスでのキャッシュミス状態、もしくは、アンキャッシュロードアクセス状態の何れかであるかを確認する(S35)。
 コンテキストスイッチ部104は、アクセス状態が、ロードアクセスでのキャッシュミス状態またはアンキャッシュロードアクセス状態以外の場合、つまり、キャッシュミス状態ではなく、かつ、アンキャッシュロードアクセス状態でもない場合には(S35のNo)、再度、スレッド切り替え禁止状態の確認に戻る。
 一方、コンテキストスイッチ部104は、アクセス状態が、ロードアクセスでのキャッシュヒット状態、または、アンキャッシュロードアクセス状態の場合には(S35のYes)、実行中のスレッドのコンテキストの退避と、次に実行状態となるスレッドのコンテキストの復帰操作を行わず、スレッドスケジューリング部105に再スケジューリング要求を行う(S36)。
 なおS31では、先述の図4のS21と同様の処理が行われる。本書類では、説明の便宜上、このS31のような、他のステップ(S21)での処理と同様の処理がされるステップについては、重複した説明が適宜、省略される。
 前述のように、各メモリアクセスの状態が継続する期間は、キャッシュが階層化されているかどうかや、ラストレベルキャッシュまでの階層数にも依存する。キャッシュが階層化されている場合、レベル1キャッシュ114、116でキャッシュミスした場合でも、レベル2キャッシュ118でキャッシュヒットすれば、十数サイクルでアクセスが完了する実装が可能である。このような実装がなされた場合、メモリアクセス状態の継続期間より、スレッドスケジューリング装置105のスケジューリング期間の方が長くなる場合がある。
 図6は、レベル2キャッシュ118を持つプロセッサのコンテキストスイッチ部104におけるスレッド切り替え処理の流れを示すフローチャートである。
 コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、処理中のメモリアクセスが存在した場合、次の確認をする。その確認では、レベル1データキャッシュ116と、レベル1命令キャッシュ114とのそれぞれからのアクセス状態情報により、処理中のメモリアクセスの状態が、アンキャッシュロードアクセス状態であるかを確認する(S45)。処理中のメモリアクセスの状態が、アンキャッシュロードアクセス状態でなかった場合には(S45のNo)、ロードアクセスでの、キャッシュミス状態であるかを確認する(S47)。処理中のメモリアクセス状態が、ロードアクセスでのキャッシュミス状態であった場合には(S47のYes)、さらに、レベル2キャッシュ118のアクセス状態を参照し、レベル2キャッシュ118が、キャッシュヒット状態であるかキャッシュミス状態であるか確認する(S48)。
 コンテキストスイッチ部104は、アクセス状態が、アンキャッシュロードアクセス状態の場合(S45のYes)と、ロードアクセスで、レベル1データキャッシュ116では、キャッシュミスであるが(S47のYes)、レベル2キャッシュではキャッシュヒットの状態であった場合(S48のYes)とには、何れの場合にも、次の動作をする。その動作では、実行中のスレッドのコンテキストの退避と、次に実行状態となるスレッドのコンテキストの復帰操作とを行わず、スレッドスケジューリング部105に、再スケジューリング要求を行う(S46)。その他のアクセス状態の場合には、再度、スレッド切り替え禁止状態の確認に戻る(S47のNo、S48のNo)。
 図7は、コンテキストスイッチ部104における、スレッド切り替え禁止要因がマルチサイクル命令実行中である場合の、スレッド切り替え処理を示すフローチャートである。
 スレッドスケジューリング部105からスレッド切り替え要求があった時に、切り替え対象の実行中のスレッドが、マルチサイクル命令の実行を開始していたために、スレッド切り替え禁止状態となっている場合がある。この場合の、コンテキストスイッチ部104におけるスレッド切り替え処理が示される。
 コンテキストスイッチ部104は、スレッドスケジューリング部105からのスレッド切り替え要求を検出した場合(S51のYes)、切り替え対象の実行中のスレッドにおいて、マルチサイクル命令が開始されているかを確認する(S52)。コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、マルチサイクル命令が開始されていなかった場合には(S52のNo)、次の動作をする。その動作では、切り替え対象の実行中のスレッドのコンテキストのコンテキスト部100から、コンテキストメモリ106への退避操作を行う。また、その動作では、次に実行状態となるスレッドのコンテキストの、コンテキストメモリ106からコンテキスト部100への復帰操作を行う(S53)。また、その動作では、スレッドスケジューリング部105へ、スレッド切り替え受理通知を行う(S54)。
 マルチサイクル命令の実行が開始されると、その実行が、プロセッサの状態に副作用を発生させる場合がある。そのため、一般的に、マルチサイクル命令で実行が開始されると、マルチサイクル命令の完了までの期間においては、スレッド切り替えをすることは出来ない。しかし、マルチサイクル命令が完了するまでのサイクル数や、実行するマイクロオペレーション数は、マルチサイクル命令の種類によって様々である。
 コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、マルチサイクル命令の実行が開始されていた場合(S52のYes)、次の動作をする。その動作では、命令実行部109からの情報により、実行が開始されていたマルチサイクル命令が、整数除算命令または浮動小数点収束演算命令であるかを確認する(S55)。
 コンテキストスイッチ部104は、実行が開始されていたマルチサイクル命令が、整数除算命令ではなく、かつ、浮動小数点収束演算命令でもない場合には(S55のNo)、再度、スレッド切り替え禁止状態の確認に戻る。
 一方、コンテキストスイッチ部104は、実行が開始されていたマルチサイクル命令が、整数除算命令または浮動小数点収束演算命令の場合には(S55のYes)、次の動作をする。その動作では、実行中のスレッドのコンテキストの退避と、次に実行状態となるスレッドのコンテキストの復帰操作を行わず、スレッドスケジューリング部105に、再スケジューリング要求を行う(S56)。
 図7の例では、完了までのサイクル数が比較的長いマルチサイクル命令を検出する処理の例として、ステートS55において、マルチサイクル命令が、整数除算命令または浮動小数点収束演算命令であるかを検出する例を示した。一方、検出するマルチサイクル命令は、整数除算命令または浮動小数点収束演算命令に限定する必要はなく、次のような命令が検出されればよい。つまり、その命令の実行が完了までのサイクル数が、スレッドスケジューリング部105のスケジューリング期間より長い。このような命令を特定(検出)すればよい。
 上記の操作により、スレッドスケジューリング部105のスケジューリング完了後、切り替え対象の実行中のスレッドが、マルチサイクル命令の実行を開始していたために、スレッド切り替え禁止状態となっていた場合でも、効率よく、処理が継続される。
 図8は、コンテキストスイッチ部104における、スレッド切り替え禁止要因が割り込みもしくは例外である場合の、スレッド切り替え処理を示すフローチャートである。
 スレッドスケジューリング部105からスレッド切り替え要求があった時に、切り替え対象の実行中のスレッドが、割り込みもしくは例外を受理していたために、スレッド切り替え禁止状態となっている場合がある。この場合の、コンテキストスイッチ部104におけるスレッド切り替え処理が示される。
 コンテキストスイッチ部104は、スレッドスケジューリング部105からのスレッド切り替え要求を検出した場合(S61のYes)、切り替え対象の実行中のスレッドにおいて、割り込みもしくは例外が発生しているかを確認する(S62)。
 そして、コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、割り込み、もしくは、例外が発生していなかった場合には(S62のNo)、次の動作をする。その動作では、切り替え対象の実行中のスレッドのコンテキストのコンテキスト部100からコンテキストメモリ106への退避操作を行う。また、その動作では、次に実行状態となるスレッドのコンテキストの、コンテキストメモリ106からコンテキスト部100への復帰操作を行う(S63)。また、その動作では、スレッドスケジューリング部105へ、スレッド切り替え受理通知を行う(S64)。
 一方、コンテキストスイッチ部104は、切り替え対象の実行中のスレッドで、割り込みもしくは例外が発生していた場合(S62のYes)、割り込み制御部113からの情報により、発生している割り込みもしくは例外の種類を確認する(S65)。
 そして、コンテキストスイッチ部104は、特定された割り込みもしくは例外に該当するスレッド切り替え制御レジスタの値を確認する(S66)。
 そして、コンテキストスイッチ部104は、そのレジスタ(制御レジスタ)の値(設定値)が、再スケジューリング要求動作を指示している値である場合には(S67のYes)、次の動作をする。その動作では、実行中のスレッドのコンテキストの退避と、次に実行状態となるスレッドのコンテキストの復帰操作を行わず、スレッドスケジューリング部105に、再スケジューリング要求を行う(S68)。
 一方、コンテキストスイッチ部104は、そのレジスタの設定値が、再スケジューリング要求動作を指示していない値である場合には(S67のNo)、再度、スレッド切り替え禁止状態の確認に戻る。
 割り込みもしくは例外が発生した場合、プロセッサは、スーパーバイザ状態に、そのプロセッサの状態を切り替え、割り込みルーチンや、異常処理プログラムを実行する。このスーパーバイザ状態では、一般に、スレッド切り替えは、禁止される。スレッドスケジューリング部105のスケジューリング期間は、スレッドスケジューリング部105の実装仕様により決定され、割り込みルーチンや、異常処理プログラムの処理量は、割り込みもしくは例外の種類毎に、様々である。一方、割り込みルーチンや異常処理プログラムの処理量は、それら割り込みルーチン等の作成者であれば、把握可能である。そのため、それら割り込みルーチン等の作成者であれば、割り込みルーチンや異常処理プログラムの適切な箇所で、スレッド切り替え制御レジスタの値を更新することができる。これにより、割り込みルーチンや異常処理プログラムの完了までの適切な箇所で、スレッドスケジューリング部105に再スケジューリング要求をする動作から、コンテキストの入れ替え、および、スレッドスケジューリング部105への、スレッド切り替え受理の通知を待機させる動作へと、行われる動作が切り替わる。このことで、スケジューリング完了後、切り替え対象の実行中のスレッドが、割り込みもしくは例外の発生によりスレッド切り替え禁止状態となっても、効率よく、処理が継続される。
 図9は、本発明に係るマルチスレッドプロセッサを用いたプロセッサボード40の基本構成を示すブロック図である。
 プロセッサボード40は、本発明に係るマルチスレッドプロセッサ10を備えるシステムLSI41と、オンボードメモリ407と、外部機器とのコネクタ408、409とを備え、システムLSI41と、オンボードメモリ407、および、外部機器とのコネクタ408、409との間は、オンボードバス406で接続されている。
 システムLSI41は、マルチスレッドプロセッサ10の他に、グラフィックスエンジン400と、コーデックエンジン401と、ストリームIO(input-output)ブロック403と、メモリIF(interface)ブロック404と、AVIO(Audio Visual Input Output)ブロック405とを備え、これらは、オンチップバス402を介して、相互に接続されている。
 グラフィックスエンジン400は、マルチスレッドプロセッサ10による制御の下で、GUI(Graphical User Interface)操作などにおける描画処理を行う。
 コーデックエンジン401は、マルチスレッドプロセッサ10による制御の下で、H.264やMPEG(Moving Picture Experts Group)といった動画フォーマットや、DTS(Digital Theater Systems)やAAC(Advanced Audio Coding)といったオーディオフォーマットのデコードやエンコードを行う。
 メモリIFブロック404は、マルチスレッドプロセッサ10による制御の下で、次のデータ要求を制御する。制御されるデータ要求は、オンチップバス402を介した、グラフィックスエンジン400、コーデックエンジン401、ストリームIOブロック403、AVIOブロック405、およびオンボードメモリ407との間での、データの転送等の要求である。
 ストリームIOブロック403は、マルチスレッドプロセッサ10による制御の下で、蓄積メディア、および、ネットワーク等の周辺デバイスから、圧縮画像音声ストリーム等のストリームデータを読み込む。ストリームIOブロック403は、読み込まれたストリームデータを、メモリIFブロック404やオンチップバス402を介して、オンボードメモリ407に格納し、また、その逆方向の、ストリームデータの転送を行う。
 AVIOブロック403は、マルチスレッドプロセッサ10による制御の下で、メモリIFブロック404やオンチップバス402を介して、オンボードメモリ407から、画像データや音声データ等を読み出す。そして、AVIOブロック403は、読出された画像データ等を、コーデックエンジン401やグラフィックスエンジン400へ転送し、また、その逆方向の、画像データ等の転送を行う。
 図10は、本発明に係るマルチプロセッサシステムを用いたプロセッサボード42の基本構成を示すブロック図である。
 プロセッサボード42は、本発明に係るマルチプロセッサシステム12を備えるシステムLSI42と、オンボードメモリ407と、外部機器とのコネクタ408、409とを備え、システムLSI42と、オンボードメモリ407、および、外部機器とのコネクタ408、409との間は、オンボードバス406で接続されている。
 システムLSI42は、マルチスレッドプロセッサ10の他に、グラフィックスエンジン400と、コーデックエンジン401と、ストリームIOブロック403と、メモリIFブロック404と、AVIOブロック405とを備え、これらは、オンチップバス402を介して、相互に接続されている。
 マルチスレッドプロセッサ10やマルチプロセッサシステム12において、スレッド切り替え禁止の要因が、マルチサイクル命令の実行に起因する要因や、レベル1データキャッシュ116等の、プロセッサに内蔵のキャッシュメモリに起因する要因である場合がある。この場合には、スレッド切り替え禁止期間のオーダーは、数サイクルから数十サイクルのオーダーである。これに対し、スレッド切り替え禁止の要因が、アンキャッシュのメモリアクセスや、マルチスレッドプロセッサ10に内蔵のラストレベルキャッシュのキャッシュミス等の、オンボードメモリ407へのアクセスに起因する要因である場合、スレッド切り替え禁止期間のオーダーは、数百サイクルのオーダーとなる。
 スレッドスケジューリング部105が、スケジューリング(期間91参照)を完了した後に、切り替え対象の実行中のスレッド(スレッド31)の状態が、オンボードメモリ407へのアクセスに起因するスレッド切り替え禁止状態となっていた場合(期間8L参照)がある。この場合でも、プロセッサボード40、42では、コンテキストスイッチ部104により、動的に、行われる動作を、スレッドスケジューリング部105での再スケジューリング処理(期間92参照)をする動作に切り替える(図11B上欄)ことができる。そのため、スレッドスケジューリング部105のスケジューリング完了後、切り替え対象の実行中のスレッドが、オンボードメモリ407に起因するスレッド切り替え禁止状態となっていた場合でも、新しく実行するスレッドの実行開始が、長期間待たされること(時刻6L参照)がなくなり、効率よく、処理が継続される(時刻72参照)。
 こうして、先述の通り、スレッド切り替え禁止状態の期間8(図11A、図11B)が、スレッドのスケジューリングに要する期間(期間92)より長い場合(図11A、図11Bの上欄、図2のS16のYesなど参照)でも、処理の効率が、(著しく)低い効率になってしまわず、高い効率にできる。
 なお、こうして、例えば、次の動作が行われてもよい。
 つまり、第2のスレッド(図11A、図11Bのスレッド31、32を参照)の処理が実行されてもよい。
 そして、実行されるスレッドが、切り替え前における第2のスレッドから、切り替え後における第1のスレッド(図11A、図11Bのスレッド33を参照)へと切り替えられてもよい。
 そして、第1のスレッドの実行が開始される時刻は、第2のスレッドの実行が(完全に)終了するまでの期間8が終了する時刻(7Sを参照)以後の時刻でもよい。
 例えば、第1のスレッドの実行が開始される時刻が、上述の終了の時刻と同じでもよい。
 しかしながら、期間8としては、比較的短い期間8S(図11Bの下欄)だけでなく、比較的長い期間8L(図11Bの上欄、図11A)もある。
 つまり、先述のように、例えば、第2のスレッドで、期間8のうちに、メモリアクセスがされて、この期間8が、比較的短い期間8Sでなく、比較的長い期間8Lであることなどがある。
 このため、本技術以外の他の技術では、図11Aで示される状況が想定される。つまり、図11Aの技術では、比較的長い期間8Lが終了する時刻6Lに、第1のスレッド(スレッド33)の実行が開始される。このため、図11Aでは、この時刻が、図11Bの上欄の、スレッド33の開始の時刻72よりも大幅に遅い時刻になり、処理の遅延が生じてしまう。
 つまり、長い期間8Lとは、例えば、こうして生じる、処理の遅延が、弊害が生じる程度に長い期間などをいう。
 そこで、本技術においては、例えば、期間8が、比較的短い期間8S(図11Bの下欄)であるか否かが特定されてもよい(S16、 S26、 S35、 S47~S48、 S55などを参照)。
 そして、短い期間8Sであるのが特定される場合にのみ(図11Bの下欄、S16のNoなど参照)、期間8が終了する時刻(図11Bの下欄の時刻7S)に、第1のスレッドの実行が開始されてもよい。
 そして、短い期間8Sではなく、長い期間8Lであるのが特定される場合には(図11Bの上欄、S16のYesなどを参照)、その長い期間8Lの間における時刻(図11Bの上欄の時刻72)において、第1のスレッドの実行が開始されてもよい(S17などを参照)。
 これにより、図11Aの時刻62(図11Bの上欄の時刻72参照)での開始がされる。これによって、遅い時刻に開始され、処理の遅延が生じてしまうのが回避される。つまり、図11Bの上欄の時刻72(図11Aの時刻62参照)に開始されて、早い時刻に開始され、処理の遅延が回避され、処理が高速にできる。
 なお、本発明は、装置、システム、集積回路などとして実現可能であるだけでなく、その装置を構成する処理手段をステップとする方法として実現することも可能であるし、その他のカテゴリにおいて実現することなども可能である。
 以上のように、本技術に係るマルチスレッドプロセッサおよびマルチプロセッサシステムでは、スレッドのスケジューリング(期間91参照)が完了した後、スレッド切り替えを開始した時に、切り替え対象の、実行中のスレッド(スレッド31)が、スレッド切り替え禁止状態(期間8参照)となっていた場合でも、適切な動作がされる。つまり、その場合には、プロセッサの状態に応じて(期間8S、8L参照)、動的に、スレッド切り替えの動作を変更する(期間92など参照)ことにより、処理の効率を上げることができる。本技術は、このような効果を有し、マルチスレッドプロセッサ、マルチプロセッサシステム、および、これらの一方または両方を用いた、デジタルテレビ、DVDレコーダ、携帯電話機器等に搭載されるプロセッサボードに有用である。
 10 マルチスレッドプロセッサ
 11 プロセッサコア
 12 マルチプロセッサシステム
 40、42 プロセッサボード
 41 システムLSI
 43 システムLSI
 100 コンテキスト部
 101 プログラムカウンタ
 102 命令バッファ
 103 レジスタファイル
 104 コンテキストスイッチ部
 105 スレッドスケジューリング部
 106 コンテキストメモリ
 107 命令フェッチ部
 108 命令デコード部
 109 命令実行部
 110 FPU
 111 整数演算器群
 112 ロードストアユニット
 113 割り込み制御部
 114 レベル1命令キャッシュ
 115 命令TLB
 116 レベル1データキャッシュ
 117 データTLB
 118 レベル2キャッシュ
 400 グラフィックスエンジン
 401 コーデックエンジン
 402 オンチップバス
 403 ストリームIOブロック
 404 メモリIFブロック
 405 AVIOブロック
 406 オンボードバス
 407 オンボードメモリ
 408、409 外部機器とのコネクタ

Claims (12)

  1.  複数のスレッドを同時に実行可能なマルチスレッドプロセッサであって、
     実行可能状態となった1以上のスレッドから第1のスレッドを選択し、選択された前記第1のスレッドと、前記マルチスレッドプロセッサで実行中の第2のスレッドとの切り替えを要求するスレッドスケジューリング装置と、
     実行中の前記第2のスレッドのコンテキストと、実行可能状態の前記第1のスレッドのコンテキストとを入れ替えるコンテキストスイッチ装置とを備え、
     前記コンテキストスイッチ装置は、
     前記切り替えの要求がされた後に、実行中の前記第2のスレッドが、スレッドの切り替えが不能な状態となっているか否かを検出し、
     前記不能な状態となっていることが検出された場合、
     前記不能な状態を生じさせたスレッド切り替え禁止要因に基づいて、
     前記スレッド切り替え禁止要因が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ、再スケジューリング要求を通知するかを判定するマルチスレッドプロセッサ。
  2.  少なくとも1つ以上のスレッドを実行可能なプロセッサコアを複数備えたマルチプロセッサシステムであって、
     実行可能状態となった1以上のスレッドから第1のスレッドを選択し、選択された前記第1のスレッドと、1の前記プロセッサコアで実行中の第2のスレッドとの切り替えを要求するスレッドスケジューリング装置と、
     実行中の前記第2のスレッドのコンテキストと、実行可能状態の前記第1のスレッドとのコンテキストを入れ替えるコンテキストスイッチ装置を備えており、
     前記コンテキストスイッチ装置は、
     前記切り替えの要求がされた後に、実行中の前記第2のスレッドが、スレッドの切り替えが不能な状態となっているか否かを検出し、
     前記不能な状態となっていることが検出された場合、
     前記不能な状態を生じさせたスレッド切り替え禁止要因に基づいて、
     前記スレッド切り替え禁止要因が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ、再スケジューリング要求を通知するかを判定するマルチプロセッサシステム。
  3.  マルチスレッドプロセッサおよびマルチプロセッサシステムの何れかである、第1、第2のスレッドを実行する実行装置であって、
     実行可能状態となった1以上のスレッドから前記第1のスレッドを選択し、選択された前記第1のスレッドと、実行中の前記第2のスレッドとの切り替えを要求するスレッドスケジューリング装置と、
     実行中の前記第2のスレッドのコンテキストと、実行可能状態の前記第1のスレッドのコンテキストとを入れ替えるコンテキストスイッチ装置とを備え、
     前記コンテキストスイッチ装置は、
     前記切り替えの要求がされた後に、実行中の前記第2のスレッドが、スレッドの切り替えが不能な状態となっているか否かを検出し、
     前記不能な状態となっていることが検出された場合、
     前記不能な状態を生じさせたスレッド切り替え禁止要因に基づいて、
     前記スレッド切り替え禁止要因が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ、再スケジューリング要求を通知するかを判定する、
     実行装置。
  4.  前記スレッドスケジューリング装置は、
     前記再スケジューリング要求が通知された場合、
     前記第1のスレッドより優先度の高い第3のスレッドが新たに実行可能状態になっていない場合には、前記第1のスレッドと、前記第2のスレッドとは別の、実行中の第4のスレッドとの切り替えを要求し、
     優先度の高い前記第3のスレッドが、新たに実行可能状態になっていた場合には、前記第3のスレッドと、前記第4のスレッドとの切り替えを要求する、
     請求項3に記載の実行装置。
  5.  前記コンテキストスイッチ装置は、
     前記スレッドスケジューリング装置から前記要求がされた時に、
     キャッシュ制御装置から通知されるアクセス状態情報により、
     メモリアクセスの処理中であるために、前記第2のスレッドが前記不能な状態となっていることが検出された場合、
     前記アクセス状態情報により示される、前記メモリアクセスの状態の種類に応じて、
     前記メモリアクセスが完了し、スレッド切り替え禁止状態が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置へのスレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知するか、のいずれかを選択する、
     請求項3に記載の実行装置。
  6.  前記コンテキストスイッチ装置は、
     データメモリアクセスの前記アクセス状態情報が、アクセスの処理中であることを示していた場合に、
     コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知するか、
     のいずれの動作を行うかを指示するデータが設定される制御レジスタを、前記メモリアクセスのステート毎に備える、
     請求項5に記載の実行装置。
  7.  前記コンテキストスイッチ装置は、
     データメモリアクセスの前記アクセス状態情報が、アンキャッシュのロードアクセスを実行中の状態か、ロードアクセスで、キャッシュミスが発生している状態を示していれば、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知し、
     アンキャッシュのロードアクセスを実行中の状態か、ロードアクセスでキャッシュミスが発生している状態を示していなければ、
     処理中のデータメモリアクセスの完了まで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機する、
     請求項5に記載の実行装置。
  8.  2以上の階層へと階層化されたキャッシュメモリを備え、
     前記コンテキストスイッチ装置は、
     全ての前記階層のキャッシュメモリからの、メモリアクセスの前記アクセス状態情報が、キャッシュミスしている状態を示していれば、前記スレッドスケジューリング装置へ、スレッドの前記再スケジューリング要求を通知し、
     最下位層よりも上位の前記階層のキャッシュメモリ制御部からの、メモリアクセスの前記アクセス状態情報が、キャッシュミスしている状態を示していても、
     前記最下位層の前記階層のキャッシュメモリ制御部からの、メモリアクセスの前記アクセス状態情報が、キャッシュヒットしている状態を示していれば、
     処理中のメモリアクセスの完了まで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機する、
     請求項5に記載の実行装置。
  9.  前記コンテキストスイッチ装置は、
     前記スレッドスケジューリング装置から前記要求がされた時に、
     実行中の前記第2スレッドが、マルチサイクル命令の実行を開始していたために、前記不能な状態となっていることが検出された場合、
     実行を開始していた前記マルチサイクル命令のレイテンシに応じて、
     前記マルチサイクル命令が完了し、スレッド切り替え禁止状態が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知するか、のいずれかを選択する、
     請求項3に記載の実行装置。
  10.  前記コンテキストスイッチ装置は、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知する動作と、その他の動作とのいずれの動作を行うかを指示するデータが設定される制御レジスタを、各割り込みまたは例外毎に備え、
     前記スレッドスケジューリング装置から前記要求がされた時に、
     実行中の前記第2のスレッドが、割り込みもしくは例外を受理していたために、前記第2のスレッドが前記不能な状態となっていることが検出された場合、
     発生している前記割り込みもしくは例外に対応した前記制御レジスタの設定値に基づいて、
     前記割り込み処理もしくは例外処理から復帰し、前記不能な状態が解除されるまで、コンテキストの入れ替え、および、前記スレッドスケジューリング装置への、スレッド切り替え受理の通知を待機するか、
     前記スレッドスケジューリング装置へ前記再スケジューリング要求を通知するか、
     のいずれかを選択する請求項3に記載の実行装置。
  11.  請求項1に記載のマルチスレッドプロセッサと、
     前記マルチスレッドプロセッサに内蔵されるキャッシュメモリ制御装置に接続されているバス制御装置と、
     前記バス制御装置に接続されたオンボードメモリと、
     を備えたプロセッサボード。
  12.  請求項2に記載のマルチプロセッサシステムと、
     前記マルチプロセッサシステムが有する前記複数のプロセッサコアの間での共有キャッシュメモリの共有キャッシュメモリ制御装置と、
     前記共有キャッシュメモリ制御装置に接続されているバス制御装置と、
     前記バス制御装置に接続されたオンボードメモリと、
     を備えたプロセッサボード。
PCT/JP2012/002401 2011-04-19 2012-04-05 マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード WO2012144149A1 (ja)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2011-092640 2011-04-19
JP2011092640 2011-04-19

Publications (1)

Publication Number Publication Date
WO2012144149A1 true WO2012144149A1 (ja) 2012-10-26

Family

ID=47041284

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2012/002401 WO2012144149A1 (ja) 2011-04-19 2012-04-05 マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード

Country Status (1)

Country Link
WO (1) WO2012144149A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007500886A (ja) * 2003-07-25 2007-01-18 ラザ マイクロエレクトロニクス,インク. 最新型プロセッサ
JP2010061642A (ja) * 2008-07-07 2010-03-18 Intel Corp スレッドのスケジューリングテクニック

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007500886A (ja) * 2003-07-25 2007-01-18 ラザ マイクロエレクトロニクス,インク. 最新型プロセッサ
JP2010061642A (ja) * 2008-07-07 2010-03-18 Intel Corp スレッドのスケジューリングテクニック

Similar Documents

Publication Publication Date Title
JP4119945B2 (ja) タスク処理装置
US8924690B2 (en) Apparatus and method for heterogeneous chip multiprocessors via resource allocation and restriction
EP1658563B1 (en) Apparatus, and method for initiation of concurrent instruction streams in a multithreading microprocessor
KR100280460B1 (ko) 데이터 처리 장치 및 이의 복수의 스레드 처리 방법
KR101109029B1 (ko) 연산 장치
US20040215932A1 (en) Method and logical apparatus for managing thread execution in a simultaneous multi-threaded (SMT) processor
US6772355B2 (en) System and method for reducing power consumption in a data processor having a clustered architecture
JP4127848B2 (ja) タスク処理装置
US20040216101A1 (en) Method and logical apparatus for managing resource redistribution in a simultaneous multi-threaded (SMT) processor
KR100936601B1 (ko) 멀티 프로세서 시스템
JPWO2009022371A1 (ja) タスク処理装置
JP2007219581A (ja) メモリコントローラおよびこれを搭載する電子機器
KR100834180B1 (ko) 프로그램/명령어의 실행을 구동하는 “l”구동법 및그것의 아키텍처와 프로세서
KR101849110B1 (ko) 다음-명령-타입 필드
JP2000207202A (ja) 制御装置およびデ―タ処理装置
JP5155336B2 (ja) タスク処理装置
WO2012144149A1 (ja) マルチスレッドプロセッサ、マルチプロセッサシステム、実行装置、プロセッサボード
WO2011024330A1 (ja) アイドル状態検出回路、半導体集積回路、信号処理装置、アイドル状態検出方法
JP5204740B2 (ja) タスク処理装置
JP5017784B2 (ja) プロセッサ及びこのプロセッサ適用される割込み処理制御方法
JP4631442B2 (ja) プロセッサ
JP2008059455A (ja) マルチプロセッサ
JP2008269597A (ja) タスク処理装置
JPH11338735A (ja) システムlsi
JP2006099335A (ja) コンテキスト処理装置

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12774616

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP