The present disclosure generally relates to the field of electronics. More particularly, an embodiment relates to mid-thread pre-emption with software assisted context switch.
When running GPGPU (General-Purpose Computation on Graphics Processing Unit) workloads and the hardware is required for other workloads, a mechanism may be used to pre-empt or interrupt the GPGPU workload. This generally requires the completion of all existing or executing threads in the hardware in response to an interruption. This mechanism works well for threads which are expected to complete in a short amount of time. However, when threads run indefinitely or for a long duration, the response time in context switch can be very long and sometimes even cause a page fault.
The detailed description is provided with reference to the accompanying figures. In the figures, the left-most digit(s) of a reference number identifies the figure in which the reference number first appears. The use of the same reference numbers in different figures indicates similar or identical items.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of various embodiments. However, various embodiments may be practiced without the specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail so as not to obscure the particular embodiments. Further, various aspects of embodiments may be performed using various means, such as integrated semiconductor circuits (“hardware”), computer-readable instructions organized into one or more programs (“software”), or some combination of hardware and software. For the purposes of this disclosure reference to “logic” shall mean either hardware, software, firmware, or some combination thereof.
Some embodiments provide mid-thread pre-emption with software assisted context switch. An embodiment pre-empts or interrupts the GPGPU kernels mid-thread. The state of the system is saved and could be restored at a later point to continue execution of the preempted kernels to completion. By contrast, other solutions may rely either on completion of a work load completely or on completion of a work load at a much coarser granularity before being able to switch to a different workload.
For example, if multiple threads within a thread group are dispatched for execution, some solutions may provide a mechanism to pre-empt the dispatch at thread group boundaries only. Any dispatched threads then need to complete their tasks. This increases the response time of a GPU to critical interrupts. With mid-thread pre-emption, all threads that are already in execution mode, may be interrupted at any instruction boundary. This in turn improves the performance of switching between workloads.
As discussed herein, GPGPU refers to General-Purpose Computation on Graphics Processing Unit (GPU). The GPU may include graphics logic or other types of logic that normally perform computation(s) relating to graphics task(s), such as operation(s) that manipulate an image, frame, scene, etc., but in case of GPGPU, they are also capable of executing or performing general-purpose computation(s). While some embodiments are discussed with reference to graphics logic, embodiments are not limited to graphics related logic and may be also applied to other types of non-graphic (e.g., general-purpose) logic. Moreover, various embodiments may be performed for any type of computing device such as a desktop computer, a mobile computer (such as a smartphone, tablet, UMPC (Ultra-Mobile Personal Computer), laptop computer, Ultrabook™ computing device, smart watch, smart glasses, etc.), a work station, etc., which may be embodied on a SOC (System On Chip) platform in an embodiment.
Accordingly, some embodiments provide a highly flexible solution that could be used in other applications, e.g., where workloads need to be stopped before completion to make way for higher priority operations. Some embodiments improve the responsiveness of hardware to application requests. They also allow for the graphics logic to be multipurpose.
Some embodiments may be applied in computing systems that include one or more processors (e.g., with one or more processor cores), such as those discussed with reference to
In an embodiment, the processor 102-1 may include one or more processor cores 106-1 through 106-M (referred to herein as “cores 106,” or “core 106”), a cache 108, and/or a router 110. The processor cores 106 may be implemented on a single integrated circuit (IC) chip. Moreover, the chip may include one or more shared and/or private caches (such as cache 108), buses or interconnections (such as a bus or interconnection 112), graphics and/or memory controllers (such as those discussed with reference to
In one embodiment, the router 110 may be used to communicate between various components of the processor 102-1 and/or system 100. Moreover, the processor 102-1 may include more than one router 110. Furthermore, the multitude of routers 110 may be in communication to enable data routing between various components inside or outside of the processor 102-1.
The cache 108 may store data (e.g., including instructions) that are utilized by one or more components of the processor 102-1, such as the cores 106. For example, the cache 108 may locally cache data stored in a memory 114 for faster access by the components of the processor 102 (e.g., faster access by cores 106). As shown in
As shown in
Generally, the state in the hardware (e.g., logic 140) may be categorized into: (a) state in fixed function hardware; (b) state of the threads (i.e., registers and Instruction Pointer, etc.); and (c) SLM (or Shared Local Memory, which refers to memory that is used by graphics logic/GPU for caching/storage of intermediate results, as well as other scatter/gather operations that otherwise are directed to global/main memory, e.g., including buffered data to be reused frequently). For example, SLM may support operations that require different threads to share data and/or pass data between them.
Some context save and restore processes may be built into hardware as state machines, e.g., where, on a halt condition, some form of DMA (Direct Memory Access) engine/logic writes all the hardware state into memory in a predefined location, and following a predefined sequence. In an embodiment, existing controls in a programmable engine (EU or Execution Unit of graphics logic/GPU) are used to move the content of the thread to memory with assistance from software. An exception handling hardware/logic that is primarily use for debug may be extended for this purpose. Also, a kernel may jump to a system routine, which can move some context of hardware to memory.
This mechanism may be used to save the state of EU in response to an interrupt. Although, some features may already exist, they are generally limited to handling some registers only and all of thread state may not be saved. In addition, the process of system routine requires the routine to return to application routine after completion. In an embodiment, the system can exit after completing a system routine. The change is depicted in
Three cases are shown in
Case A: Existing system routine handlers start from a given application routine. The new threads launched are application routine. The system routine returns to application routine for completion.
Case B: An embodiment provides a way for the system routine to complete the write operations to memory and terminate the workload without returning to application routine. This enables the launch of new workloads.
Case C: One embodiment provides a way to start a thread with a system routine and then move to application routine, which will complete the workload to termination.
In an embodiment, the sequence of saving the graphics hardware/logic 140 state is as follows:
(a) On an interrupt, the fixed function (e.g., thread spawner logic 302) ensures no new threads are spawned into the pipeline (e.g., of the EUs in EU complex 304);
(b) The fixed function (e.g., thread spawner logic 302) requests the threads to stop execution;
(c) The threads complete any outstanding pending cycles in the pipeline and complete stops;
(d) When the system becomes idle, the threads proceed with a system routine;
(e) The system routine moves the hardware state of the threads (where all work is handled in software in an embodiment), such as intermediate registers, flow control pointers, stacks, architectural control registers, etc. to memory 308 (e.g., where the location of such a move is predetermined in one embodiment);
(f) When all threads have completed the data move, the system routine moves the control to the fixed function (which also has access to a DMA engine such as SLM 306);
(g) This DMA now moves the SLM 306 data to memory 308;
(h) When this DMA move is completed, the rest of the state, such as pipelined state, walker state, and intermediate state machines that handle barriers are all saved into context; and
(i) The hardware can now flush and execute a new context.
By contrast, previous solutions involved the use of a predefined hardware state machine to handle such data movement. Per some embodiments, a new hybrid approach improves flexibility and reduces risks since a software approach is used.
Referring to
At an operation 506, it is determined whether all pending tasks in the pipeline are completed (e.g., all running threads have completed their tasks at the instruction level granularity) to bring the rest of the system into idle state. At an operation 508, a hardware/software combination of mechanisms are used to move/copy the context, including thread and SLM data to memory (such as discussed with reference to
A similar sequence to the above-discussed saving sequence may be used for restoring a previously saved context. More particularly,
Referring to
Moreover, the processors 602 may have a single or multiple core design. The processors 602 with a multiple core design may integrate different types of processor cores on the same integrated circuit (IC) die. Also, the processors 602 with a multiple core design may be implemented as symmetrical or asymmetrical multiprocessors. In an embodiment, one or more of the processors 602 may be the same or similar to the processors 102 of
A chipset 606 may also communicate with the interconnection network 604. The chipset 606 may include a graphics memory control hub (GMCH) 608, which may be located in various components of system 600 (such as those shown in
The GMCH 608 may also include a graphics interface 614 that communicates with a display device 616. In one embodiment, the graphics interface 614 may communicate with the display device 616 via an accelerated graphics port (AGP) or Peripheral Component Interconnect (PCI) (or PCI express (PCIe) interface). In an embodiment, the display 616 (such as a flat panel display) may communicate with the graphics interface 614 through, for example, a signal converter that translates a digital representation of an image stored in a storage device such as video memory or system memory into display signals that are interpreted and displayed by the display 616. The display signals produced by the display device may pass through various control devices before being interpreted by and subsequently displayed on the display 616.
A hub interface 618 may allow the GMCH 608 and an input/output control hub (ICH) 620 to communicate. The ICH 620 may provide an interface to I/O device(s) that communicate with the computing system 600. The ICH 620 may communicate with a bus 622 through a peripheral bridge (or controller) 624, such as a peripheral component interconnect (PCI) bridge, a universal serial bus (USB) controller, or other types of peripheral bridges or controllers. The bridge 624 may provide a data path between the CPU 602 and peripheral devices. Other types of topologies may be utilized. Also, multiple buses may communicate with the ICH 620, e.g., through multiple bridges or controllers. Moreover, other peripherals in communication with the ICH 620 may include, in various embodiments, integrated drive electronics (IDE) or small computer system interface (SCSI) hard drive(s), USB port(s), a keyboard, a mouse, parallel port(s), serial port(s), floppy disk drive(s), digital output support (e.g., digital video interface (DVI)), or other devices.
The bus 622 may communicate with an audio device 626, one or more disk drive(s) 628, and a network interface device 630 (which is in communication with the computer network 603). Other devices may communicate via the bus 622. Also, various components (such as the network interface device 630) may communicate with the GMCH 608 in some embodiments. In addition, the processor 602 and the GMCH 608 may be combined to form a single chip. Furthermore, a graphics accelerator may be included within the GMCH 608 in other embodiments.
Furthermore, the computing system 600 may include volatile and/or nonvolatile memory (or storage). For example, nonvolatile memory may include one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically EPROM (EEPROM), a disk drive (e.g., 628), a floppy disk, a compact disk ROM (CD-ROM), a digital versatile disk (DVD), flash memory, a magneto-optical disk, or other types of nonvolatile machine-readable media that are capable of storing electronic data (e.g., including instructions).
As illustrated in
In an embodiment, the processors 702 and 704 may be one of the processors 602 discussed with reference to
At least one embodiment may be provided within the processors 702 and 704. For example, one or more components of system 700 may include logic 140 of
The chipset 720 may communicate with a bus 740 using a PtP interface circuit 741. The bus 740 may communicate with one or more devices, such as a bus bridge 742 and I/O devices 743. Via a bus 744, the bus bridge 742 may communicate with other devices such as a keyboard/mouse 745, communication devices 746 (such as modems, network interface devices, or other communication devices that may communicate with the computer network 603), audio I/O device 747, and/or a data storage device 748. The data storage device 748 may store code 749 that may be executed by the processors 702 and/or 704.
Moreover, the scenes, images, or frames discussed herein (e.g., which may be processed by the graphics logic in various embodiments) may be captured by an image capture device (such as a digital camera (that may be embedded in another device such as a smart phone, a tablet, a laptop, a stand-alone camera, etc.) or an analog device whose captured images are subsequently converted to digital form). Also, the scenes, images, or frames discussed herein may be generated by art design, game design, or any kind of 3D/2D (two dimensional/three dimensional) industry design. For example, a scene may refer to a set of geometry structure and related texture maps, lighting effects, etc. Moreover, the image capture device may be capable of capturing multiple frames in an embodiment. Further, one or more of the frames in the scene are designed/generated on a computer in some embodiments. Also, one or more of the frames of the scene may be presented via a display (such as the display discussed with reference to
In some embodiments, one or more of the components discussed herein can be embodied as a System On Chip (SOC) device.
As illustrated in
The I/O interface 840 may be coupled to one or more I/O devices 870, e.g., via an interconnect and/or bus such as discussed herein with reference to other figures. I/O device(s) 870 may include one or more of a keyboard, a mouse, a touchpad, a display, an image/video capture device (such as a camera or camcorder/video recorder), a touch screen, a speaker, or the like. Furthermore, SOC package 802 may include/integrate the logic 140 in an embodiment. Alternatively, the logic 140 may be provided outside of the SOC package 802 (i.e., as a discrete logic).
The following examples pertain to further embodiments. Example 1 includes an apparatus comprising: logic, the logic at least partially comprising hardware logic, to cause one or more threads executing on a Graphics Processing Unit (GPU) to stop at an instruction level granularity in response to a request to pre-empt the one or more threads, wherein context data of the one or more threads are to be copied to memory in response to completion of the one or more threads at the instruction level granularity. Example 2 includes the apparatus of example 1, further comprising Shared Local Memory (SLM) to store the context data prior to copying the context data to the memory. Example 3 includes the apparatus of example 2, wherein the logic is further to copy the context data from the SLM to the memory. Example 4 includes the apparatus of example 3, wherein the logic to copy the context data is to comprise a Direct Memory Access (DMA) logic. Example 5 includes the apparatus of example 1, wherein the context data of the one or more threads are to be copied to the memory in response to one or more software instructions. Example 6 includes the apparatus of example 1, wherein the logic is to cause all threads executing on the GPU to stop at the instruction level granularity in response to the request. Example 7 includes the apparatus of example 1, wherein the one or more threads or a thread corresponding to the pre-emption request are to be executed as General-Purpose Computation on Graphics Processing Unit (GPGPU) on the GPU. Example 8 includes the apparatus of example 1, comprising thread spawner logic to spawn the one or more threads. Example 9 includes the apparatus of example 1, wherein a processor is to comprise the logic. Example 10 includes the apparatus of example 1, wherein one or more of a processor having one or more processor cores, the logic, or the memory are on a single integrated circuit die.
Example 11 includes a computer-readable medium comprising one or more instructions that when executed on a processor configure the processor to perform one or more operations to: cause one or more threads executing on a Graphics Processing Unit (GPU) to stop at an instruction level granularity in response to a request to pre-empt the one or more threads, wherein context data of the one or more threads are to be copied to memory in response to completion of the one or more threads at the instruction level granularity. Example 12 includes the computer-readable medium of example 11, further comprising one or more instructions that when executed on the processor configure the processor to perform one or more operations to cause the context data of the one or more threads to be copied to the memory in response to one or more software instructions. Example 13 includes the computer-readable medium of example 11, further comprising one or more instructions that when executed on the processor configure the processor to perform one or more operations to cause all threads executing on the GPU to stop at the instruction level granularity in response to the request. Example 14 includes the computer-readable medium of example 11, wherein the one or more threads or a thread corresponding to the pre-emption request are to be executed as General-Purpose Computation on Graphics Processing Unit (GPGPU) on the GPU. Example 15 includes the computer-readable medium of example 11, further comprising one or more instructions that when executed on the processor configure the processor to perform one or more operations to cause spawning of the one or more threads.
Example 16 includes a method comprising: causing one or more threads executing on a Graphics Processing Unit (GPU) to stop at an instruction level granularity in response to a request to pre-empt the one or more threads, wherein context data of the one or more threads are copied to memory in response to completion of the one or more threads at the instruction level granularity. Example 17 includes the method of example 16, further comprising causing the context data of the one or more threads to be copied to the memory in response to one or more software instructions. Example 18 includes the method of example 16, further comprising causing all threads executing on the GPU to stop at the instruction level granularity in response to the request. Example 19 includes the method of example 16, further comprising executing the one or more threads or a thread corresponding to the pre-emption request as General-Purpose Computation on Graphics Processing Unit (GPGPU) on the GPU. Example 20 includes the method of example 16, further comprising causing spawning of the one or more threads.
Example 21 includes a system comprising: a processor having one or more processor cores; memory to store data, corresponding to at least one frame of a scene, to be accessed by at least one of the one or more processor cores; a display device to present the at least one frame of the scene; logic, the logic at least partially comprising hardware logic, to cause one or more threads executing on a Graphics Processing Unit (GPU) to stop at an instruction level granularity in response to a request to pre-empt the one or more threads, wherein context data of the one or more threads are to be copied to the memory in response to completion of the one or more threads at the instruction level granularity. Example 22 includes the system of example 21, further comprising Shared Local Memory (SLM) to store the context data prior to copying the context data to the memory. Example 23 includes the system of example 21, wherein the context data of the one or more threads are to be copied to the memory in response to one or more software instructions. Example 24 includes the system of example 21, wherein the logic is to cause all threads executing on the GPU to stop at the instruction level granularity in response to the request. Example 25 includes the system of example 21, wherein the one or more threads or a thread corresponding to the pre-emption request are to be executed as General-Purpose Computation on Graphics Processing Unit (GPGPU) on the GPU. Example 26 includes the system of example 21, comprising thread spawner logic to spawn the one or more threads. Example 27 includes the system of example 21, wherein the processor is to comprise the logic. Example 28 includes the system of example 21, wherein one or more of the processor, the logic, or the memory are on a single integrated circuit die.
Example 29 includes an apparatus comprising means to perform a method as set forth in any preceding example.
Example 30 includes machine-readable storage including machine-readable instructions, when executed, to implement a method or realize an apparatus as set forth in any preceding example.
In various embodiments, the operations discussed herein, e.g., with reference to
Additionally, such computer-readable media may be downloaded as a computer program product, wherein the program may be transferred from a remote computer (e.g., a server) to a requesting computer (e.g., a client) by way of data signals provided in a carrier wave or other propagation medium via a communication link (e.g., a bus, a modem, or a network connection).
Reference in the specification to “one embodiment” or “an embodiment” means that a particular feature, structure, and/or characteristic described in connection with the embodiment may be included in at least an implementation. The appearances of the phrase “in one embodiment” in various places in the specification may or may not be all referring to the same embodiment.
Also, in the description and claims, the terms “coupled” and “connected,” along with their derivatives, may be used. In some embodiments, “connected” may be used to indicate that two or more elements are in direct physical or electrical contact with each other. “Coupled” may mean that two or more elements are in direct physical or electrical contact. However, “coupled” may also mean that two or more elements may not be in direct contact with each other, but may still cooperate or interact with each other.
Thus, although embodiments have been described in language specific to structural features and/or methodological acts, it is to be understood that claimed subject matter may not be limited to the specific features or acts described. Rather, the specific features and acts are disclosed as sample forms of implementing the claimed subject matter.
Number | Name | Date | Kind |
---|---|---|---|
9384036 | Barroso | Jul 2016 | B1 |
20090327662 | Jiang et al. | Dec 2009 | A1 |
20130124838 | Shah et al. | May 2013 | A1 |
20130162661 | Bolz et al. | Jun 2013 | A1 |
20130238938 | Baliga | Sep 2013 | A1 |
20140022263 | Hartog et al. | Jan 2014 | A1 |
20140109102 | Duncan et al. | Apr 2014 | A1 |
20140184617 | Palmer et al. | Jul 2014 | A1 |
20150212819 | Giroux | Jul 2015 | A1 |
Number | Date | Country |
---|---|---|
106662995 | May 2017 | CN |
3172660 | May 2017 | EP |
2017-518575 | Jul 2017 | JP |
20160141825 | Jan 2016 | WO |
Entry |
---|
International Search Report and Written Opinion received for International Patent Application No. PCT/US2015/036538, dated Oct. 6, 2015, 12 pages. |
Communication received for European Patent Application No. 15823986.3 dated Mar. 2, 2017, 2 pages. |
International Preliminary Report on Patentability received for International Application No. PCT/US2015/036538, dated Feb. 2, 2015, 9 pages. |
Office Action received for Japanese Patent Application No. 2016-570317 dated Nov. 8, 2017, 6 pages including 3 pages of English translation. |
Extended European Search Report received for European Patent Application No. 15823986.3, dated Feb. 20, 2018, 12 pages. |
Number | Date | Country | |
---|---|---|---|
20160026494 A1 | Jan 2016 | US |