Technology for increasing efficiency in multi-strand processing plants

By dividing tasks into subtasks and using a hardware preprocessor for preemptive execution, the method addresses inefficiencies in GPU context switching, enhancing performance and reducing complexity in multi-threaded operations.

DE102013016871B4Active Publication Date: 2024-09-12NVIDIA CORP
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
DE102013016871
Authority / Receiving Office
DE · DE
Patent Type
Patents
Current Assignee / Owner
Priority Date
2012-10-12
Filing Date
2013-10-11
Publication Date
2024-09-12
Estimated Expiration
2033-10-11

AI Technical Summary

Technical Problem

Existing methods for context switching in multi-threaded operations with GPUs result in significant processing time penalties due to long pipelines and large context states, leading to inefficiencies and increased complexity.

Method used

A method and computing device that divide tasks into smaller subtasks, allowing preemptive execution of higher priority tasks without the need for complex context switching, using a hardware preprocessor to manage task prioritization and execution.

Benefits of technology

This approach eliminates the need for context switching in individual processing units, reducing latency and complexity while enabling transparent task prioritization, allowing tasks of any size to be managed efficiently without programmer intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

A computer-implemented method for increasing efficiency in multi-stranded processing units of a computing device comprising a preprocessor (410), a copy unit and a processor cluster array (230), wherein the method comprises: Receiving an initial task to be performed by a copying unit; Subdividing, by the preprocessor, the first task into a first group of subtasks, where each subtask in the first group of subtasks is smaller than a threshold size and is to be executed by the copy unit; Output at least one subtask from the first group of subtasks to the copying unit for execution; Receiving a second task to be executed by the copying unit, the second task having a higher priority than the first task; Subdivide, by the preprocessor, the second task into a second group of subtasks, each subtask in the second group of subtasks being smaller than the threshold size and to be executed by the copy unit; Prioritizing the first task by sending at least one subtask from the second group of subtasks to the copying unit for execution before all subtasks from the first group of subtasks are sent to the copying unit for execution; and Output at least one further subtask from the first group of subtasks to the copying unit for execution, after at least one subtask from the second group of subtasks has been output to the copying unit.
Need to check novelty before this filing date? Find Prior Art

Description

BACKGROUND OF THE INVENTIONField of the invention

[0001] The invention relates generally to scheduling and, more particularly, to a method and computing device for increasing performance and efficiency in multi-threaded processing devices. Description of the state of the art

[0002] Computer systems typically share hardware components between multiple applications. A central processing unit (CPU) executes an application until an event causes a context switch to another application. A context switch can be triggered by certain operating conditions, such as reaching a specific point in the execution flow that requires some action from another process or hardware device, the expiration of a time unit allocated to a process, or the system needing to execute a higher-priority (i.e., preempt) process.

[0003] There are several common approaches to implementing context switching. In one implementation, the CPU can pause processing at an instruction boundary, push some context state onto the stack, and load another context. In another approach, implemented by graphical processing units (GPUs), the GPU stops issuing new instructions and waits for the current work in a parallel processing line or pipeline to complete (i.e., wait-to-quiet, or WFI). In this approach, the GPU does not need to save any context state because the already issued workload is allowed to finish processing. In another approach, implemented by GPUs, the GPU can pause processing of any work currently in the pipeline, flush the context state to memory, and load another context.

[0004] Typically, a GPU context state is significantly larger than a CPU context state. Furthermore, GPUs typically implement longer pipelines that require hundreds or thousands of clock cycles to complete. Therefore, each of the latter two approaches mentioned above introduces a significant penalty in processing time during a context switch. In the first approach (the WFI approach), the processing of previously issued instructions in the pipeline must be completed, which requires hundreds or thousands of clock cycles, before new instructions associated with the other context can be issued. In the second approach, storing the large GPU context state can also require hundreds or even thousands of clock cycles. US Pat. No. 7,506,134 B1 discloses matrix multiplications in parallel processing units.US 2011 / 0292057 A1 describes a method for dynamically determining bandwidth and allocating processing tasks. US 6 260 058 B1 discloses a method for processing tasks of different priorities.

[0005] What is needed is an effective approach for executing multi-threaded operations with different priorities in GPUs that have large graphics pipelines or parallel processing lines. OVERVIEW OF THE INVENTION

[0006] This object is achieved by the features of the independent claims. Preferred embodiments are specified in the dependent claims. One embodiment of the present invention provides a method for increasing efficiency in multi-threaded processing units according to claim 1. The method comprises, inter alia, the following steps: receiving a first task to be executed by a copy unit, dividing the first task into a first group of subtasks, and issuing at least one subtask from the first group of subtasks to the copy unit for execution, wherein each subtask in the first group of subtasks is smaller than a threshold size.The method further comprises the step of receiving a second task to be executed by the copying unit (the second task having a higher priority than the first task), dividing the second task into a second group of subtasks, and preempting the first task by issuing at least one subtask from the second group of subtasks to the copying unit for execution before issuing all subtasks from the first group of subtasks to the copying unit for processing, wherein each subtask in the second group of subtasks is smaller than the threshold size.

[0007] A further embodiment of the present invention provides a computing device for increasing efficiency in multi-threaded processing units according to claim 10. The system includes, among other things, a copy unit configured to execute tasks and a preprocessor connected to the copy unit. The preprocessor is configured to execute the above-mentioned method.

[0008] An advantage of the disclosed technique is that context switching is unnecessary in each individual processing unit, and therefore the processing units are not implemented with complex scheduling logic and / or context switching features. Applications can be preempted simply by allowing small tasks to complete execution and then switching to the higher-priority task. Furthermore, the technique is completely transparent to a program generator, which can generate tasks of arbitrary size without having to consider the latency that may be generated in the system and prevent execution of higher-priority tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] To understand the manner in which the above-mentioned features of the present invention are achieved, a more particular description of the invention, briefly summarized above, may be given by reference to embodiments, some of which are illustrated in the accompanying drawings. It should be noted, however, that the accompanying drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention is capable of other equally effective embodiments. Fig. 1 is a block diagram illustrating a computer system configured to implement one or more aspects of the present invention; Fig. 2 is a block diagram of a parallel processing subsystem for the computer system of Fig. 1 according to an embodiment of the present invention; Fig. 3A is a block view of the front area of Fig. 2 according to an embodiment of the present invention; Fig. Figure 3B is a block diagram of a general processing cluster within the parallel processing units of Fig. 2 according to an embodiment of the present invention; Fig. Figure 3C is a block diagram of a portion of the data stream multiprocessor of Fig. 3B according to an embodiment of the present invention; Fig. 4 shows the parallel processing unit (GPU) from Fig. 2 according to an embodiment of the present invention; Fig. 5A and Fig. 5B show two approaches for dividing a task into a group of subtasks according to an embodiment of the present invention; and Fig. 6 is a flowchart of method steps for increasing efficiency in multi-threaded processing units according to an embodiment of the present invention.

[0010] For clarity, identical reference numerals have been used, where applicable, to designate identical elements where they appear similarly in the figures. It should be noted that features of one embodiment may be incorporated into other embodiments without further notice. DETAILED DESCRIPTION

[0011] In the following description, numerous specific details are set forth in order to provide a more thorough understanding of the present disclosure. However, it will be apparent to one skilled in the art that the invention may be practiced without one or more of these specific details. System overview

[0012] Fig. 1 is a block diagram illustrating a computer system 100 configured to implement one or more aspects of the present invention. Computer system 100 includes a central processing unit (CPU) 102 and system memory 104 communicating via an interconnect path that may include a memory bridge 105. Memory bridge 105, which may be, for example, a northbridge chip, is connected to an I / O (input / output) bridge 107 via a bus or other communications path 106 (e.g., a HyperTransport interconnect). I / O bridge 107, which may be, for example, a southbridge chip, receives user input from one or more user input devices 108 (e.g., keyboard, mouse) and forwards the input to CPU 102 via communications path 106 and memory bridge 105.A parallel processing subsystem 112 is connected to the memory bridge 105 via a bus or a second communication path 113 (e.g., Peripheral Component Interconnect Express (PCI), accelerated graphics port, or a HyperTransport interconnect). In one embodiment, the parallel processing subsystem 112 is a graphics subsystem that provides pixels to a display device 110 (e.g., a conventional CRT-based monitor or a liquid crystal display). A system disk 114 is also connected to the I / O bridge 107. A switch 116 establishes connections between the I / O bridge 107 and other components, such as a network adapter 118 and various add-in cards 120 and 121.Other components (not explicitly shown) including a universal serial bus (USB) or other port connections, compact disk (CD) drives, digital video disk (DVD) drives, movie recorders, and the like may also be connected to the I / O bridge 107. The various communication paths described in . Fig. 1, including the specifically mentioned communication paths 106 and 113, may be implemented using any suitable protocols, such as PCI Express, AGP (Accelerated Graphics Port), HyperTransport, or any other bus or point-to-point communication protocol(s), and connections between different devices may use different protocols, as is known in the art.

[0013] In one embodiment, parallel processing subsystem 112 includes circuitry optimized for graphics and video processing, including, for example, video output circuitry, and forms a graphics processing unit (GPU). In another embodiment, parallel processing subsystem 112 includes circuitry optimized for general-purpose processing while preserving the underlying computing architecture described in greater detail. In yet another embodiment, parallel processing subsystem 112 may be integrated with one or more other system elements in a single subsystem, such as by connecting memory bridge 105, CPU 102, and I / O bridge 107 to form a system on a chip (SoC).

[0014] It should be noted that the system described herein is only illustrative and that variations and modifications are possible. The interconnect topology, including the number and arrangement of bridges, the number of CPUs 102, and the number of parallel processing subsystems 112, may be modified as needed. For example, in some embodiments, system memory 104 is connected to CPU 102 directly rather than via a bridge, and other devices communicate with system memory 104 via memory bridge 105 and CPU 102. In other alternative topologies, parallel processing subsystem 112 is connected to I / O bridge 107 or directly to CPU 102 rather than to memory bridge 105. In still other embodiments, I / O bridge 107 and memory bridge 105 may be integrated into a single chip rather than being provided as one or more discrete devices.Larger embodiments may include two or more CPUs 102 and two or more parallel processing systems 112. The specific components shown herein are optional; for example, any number of add-in cards or peripheral devices may be supported. In some embodiments, switch 116 may not be present, and network adapter 118 and add-in cards 120, 121 may be connected directly to I / O bridge 107.

[0015] Fig. 2 shows a parallel processing subsystem 112 according to an embodiment of the present invention. As shown, the parallel processing subsystem 112 includes one or more parallel processing units (PPUs) 202, each of which is connected to a local parallel processing (PP) memory 204. Generally, a parallel processing subsystem includes a number of PPUs, where U ≥ 1. (Herein, multiple representatives of like objects are designated by reference numerals indicating the object, and numbers in parentheses indicate the representative where necessary.) The PPUs 202 and the parallel processing memories 204 may be implemented using one or more integrated circuit devices, such as programmable processors, application-specific integrated circuits (ASICs), or memory devices, or in other technically feasible ways.

[0016] It is back on Fig. 1 and Fig. 2; in some embodiments, some or all of the PPUs 202 in the parallel processing subsystem 112 are graphics processors with image generation pipelines that may be configured to perform various operations related to generating pixel data from graphics data supplied from the CPU 102 and / or system memory 104 via the memory bridge 105 and the second communication path 113, interacting with the local parallel processing memory 204 (which may be used as graphics memory, e.g., including a conventional block buffer) to store and update pixel data, provide pixel data to the display device 110, and the like. In some embodiments, the parallel processing subsystem 112 may include one or more PPUs 202 operating as graphics processors and may have one or more other PPUs 202 used for general-purpose computations.The PPUs may be identical or different, and each PPU may have dedicated parallel processing memory or memory devices or no dedicated parallel processing memory or memory devices. One or more PPUs 202 in the parallel processing subsystem 112 may output data to the display devices 110, or each PPU 202 in the parallel processing subsystem 112 may output data to one or more display devices 110.

[0017] In operation, the CPU 102 is the overarching processor of the computer system 100, and controls and coordinates the operations of other system components. In particular, the CPU 102 issues instructions that control the operation of the PPUs 202. In some embodiments, the CPU 102 writes a stream of instructions for each PPU 202 into a data structure (in Fig. 1 or Fig. 2 not explicitly shown), which may be located in system memory 104, parallel processing memory 204, or another memory location accessible by both CPU 102 and PPU 202. A pointer to each data structure is stored in a shift buffer (i.e., a buffer in memory that stores an instruction stream for PPU 202) to initiate processing of the instruction stream in the data structure. PPU 202 reads instruction streams from one or more shift buffers and then executes instructions asynchronously relative to the operation of CPU 102. Execution priorities may be specified to each shift buffer by an application program via device driver 103 to control the scheduling of the various shift buffers.

[0018] Let us now return to Fig. 2 and on Fig. 1; Each PPU 202 includes an I / O (input / output) unit 205 that communicates with the rest of computer system 100 via communication path 113, which is connected to memory bridge 105 (or, in an alternative embodiment, directly to CPU 102). The connection of PPU 202 to the rest of computer system 100 may also be different. In some embodiments, parallel processing subsystem 112 is implemented as an add-in card that can be inserted into an expansion slot of computer system 100. In other embodiments, a PPU 202 may be integrated on a single chip along with a bus bridge, such as memory bridge 105 or I / O bridge 107. In still other embodiments, some or all elements of PPU 202 may be integrated on a single chip along with CPU 102.

[0019] In one embodiment, communication path 113 is a PCI Express interconnect in which each PPU 202 is assigned dedicated lanes, as is known in the art. Other communication paths may also be used. An I / O unit 205 generates packets (or other signals) for transmission on communication path 113 and also receives any incoming packets (or other signals) from communication path 113, directing the incoming packets to appropriate components of PPU 202. For example, commands related to processing tasks may be directed to a higher-level interface 206, while commands related to memory operations (e.g., reading from or writing to parallel processing memory 204) may be directed to a memory intersection unit 210.The higher-level interface 206 reads each shift buffer and outputs the instruction stream stored in the shift buffer to a front-end area 212.

[0020] Each PPU 202 advantageously implements a highly parallel processing architecture. As shown in detail, the PPU 202(0) includes a processing cluster array 230 containing a number C of general purpose processing clusters (GPCs) 208, where C ≥ 1. Each GPC 208 is capable of executing a large number (e.g., hundreds or thousands) of threads concurrently, where each thread is an instance of a program. In various applications, different GPCs 208 may be assigned to different types of programs or to execute different types of computations. The allocation of GPCs 208 may vary depending on the workload incurred for each type of program or computation.

[0021] The GPCs 208 receive processing tasks to be executed from a work distribution unit within a task / work unit 207. The work distribution unit receives pointers to processing tasks encoded as task metadata (TMD) and stored in memory. The pointers to the TMD are contained in the instruction stream, which is stored as a sliding buffer and received by the front-end unit 212 from the higher-level interface 206. Processing tasks, which may be encoded as TMDs, contain indices of data to be processed, as well as state parameters and commands that specify how the data is to be processed (e.g., which program is to be executed). The task / work unit 207 receives tasks from the front-end unit 212 and ensures that the GPCs 208 are configured to a valid state before initiating the processing specified by each TMD.A priority can be set for all TMDs, which is used to schedule the execution of processing tasks. Processing tasks can also be received from the processing cluster array 230. Optionally, the TMDs can include a parameter that controls whether the TMDs are added to the header or tail for a list of processing tasks (or a list of pointers to the processing tasks), thereby providing another level of control over priority.

[0022] The memory interface 214 includes a number D of partition units 215, each directly connected to a portion of the parallel processing memory 204, where D ≥ 1. As shown, the number of partition units 215 is generally equal to the number of dynamic random access memories (DRAM) 220. In other embodiments, the number of partition units 215 may not be equal to the number of memory devices. Those skilled in the art will recognize that the DRAM 220 may be replaced by other suitable memory devices and may generally be of conventional design. A detailed description is therefore omitted.Render targets, such as block buffers or texture maps, may be stored across DRAMs 220, allowing partition units 215 to write portions of each render target in parallel to efficiently utilize the available bandwidth of parallel processing memory 204.

[0023] Each of the GPCs 208 can process data to be written to one of the DRAMs 220 in the parallel processing memory 204. The intersection unit 210 is configured to route the output of each GPC 208 to the input of any partition unit 215 or another GPC 208 for further processing. The GPCs 208 communicate with the memory interface 214 via the intersection unit 210 to read from or write to various external storage devices. In one embodiment, the intersection unit 210 has a connection to the memory interface 214 to interface with the I / O unit 205 and also has a connection to the local parallel processing memory 204, whereby the processing cores in the different GPCs 208 are able to communicate with the system memory 104 or other memory that is not local to the PPU 202. In the Fig. In the embodiment shown in Figure 2, the intersection unit 210 is directly connected to the I / O unit 205. The intersection unit 210 may use virtual channels to separate traffic flows between the GPCs 208 and the partition units 215.

[0024] Again, the GPCs 208 may be programmed to perform processing tasks related to a variety of applications, including, but not limited to, linear and non-linear data transformations, filtering of video and / or audio data, modeling operations (e.g., applying physical laws to determine position, velocity, and other attributes of objects), image generation operations (e.g., programs for tessellation shading, vertex shading, geometry shading, and / or pixel shading), etc.The PPUs 202 may transfer data from the system memory 104 and / or local parallel processing memory 204 to internal (on-chip) memory, process the data, and write result data back to the system memory 104 and / or the local parallel processing memory 204, thereby allowing such data to be accessed by other system components, including the CPU 102 or another parallel processing subsystem 112.

[0025] A PPU 202 may be provided with any amount of local parallel processing memory 204, including no local memory, and may use local memory and system memory in any combination. For example, a PPU 202 may be a graphics processor in a Unified Memory Architecture (UMA) embodiment. In such embodiments, little or no dedicated graphics memory (parallel processing memory) would be provided, and the PPU 202 would use system memory exclusively or almost exclusively. In UMA embodiments, a PPU 202 may be integrated into a bridge chip or a processor chip, or may be provided as a discrete chip with a high-speed connector (e.g., PCI Express) that connects the PPU 202 to system memory via a bridge chip or other communication means.

[0026] As previously stated, any number of PPUs 202 may be included in a parallel processing subsystem 112. For example, multiple PPUs 202 may be provided in a single add-in card, or multiple add-in cards may be connected to communication path 113, or one or more of the PPUs 202 may be integrated into a bridge chip. The PPUs 202 in a multi-PPU system may be identical or different from one another. For example, different PPUs 202 may have different numbers of processing cores, different amounts of local parallel processing memory, etc. When multiple PPUs 202 are present, these PPUs may operate in parallel to process data at a higher throughput than is possible with a single PPU 202.Systems including one or more PPUs 202 may be implemented in a variety of configurations and form factors, including desktop computers, mobile computers, or handheld personal computers, utility computers, workstation computers, game consoles, embedded systems, etc. Multiple simultaneous task scheduling

[0027] Multiple processing tasks can be executed concurrently in the GPCs 208, and a processing task can spawn one or more child processing tasks during execution. The task / work unit 207 receives the tasks and dynamically schedules the processing tasks and child processing tasks for execution by the GPCs 208.

[0028] Fig. Figure 3A is a block view of task / work unit 207 from Fig. 2 according to an embodiment of the present invention. The task / work unit 207 includes a task management unit 300 and the work distribution unit 340. The task management unit 300 manages tasks such that they are scheduled based on the degree of task priority. For each priority level, the task management unit 300 stores a list of pointers to the TMD 322 corresponding to the tasks in the scheduling table 321, which list may be implemented as a linked list. The TMD 322 may be stored in the PP memory 204 or in the system memory 104. The rate at which the task management unit 300 accepts tasks and stores the tasks in the scheduling table 321 is independent of the rate at which the task management unit 300 schedules tasks for execution. Therefore, the task management unit 300 may accumulate multiple tasks before scheduling the tasks.The collected tasks can then be scheduled based on priority information or using techniques such as round-robin scheduling.

[0029] The work distribution unit 340 includes a task table 345 with columns or time slots, each of which may be occupied by the TMD 322 for a task currently executing. The task management unit 300 may schedule tasks for execution if there is a free column in the task table 345. If there is no free column or time slot, a higher priority task that does not occupy a column may preempt a lower priority task that does occupy a column. When a task is preempted, the task is suspended, and if the task's execution is not complete, a pointer to the task may be added to a list of task pointers to be scheduled so that the task's execution can resume at a later time.When a child processing task is created during task execution, a pointer to the child task is added to the list of task pointers to be scheduled. A child task can be created by the TMDs 322 executing in the processing cluster array 230.

[0030] Unlike a task received by task / work unit 207 from front-end 212, child tasks are received from processing cluster array 230. Child tasks are not inserted into sliding buffers or sent to the front-end. CPU 102 is not notified when a child task is created or when data for the child task is stored in memory. Another difference between tasks delivered via sliding buffers and child tasks is that the tasks delivered via sliding buffers are defined by the application program, whereas child tasks are dynamically created during task execution. Overview of task processing

[0031] Fig. 3B is a block diagram of a GPC 208 within one of the PPUs 202 of Fig. 2 according to one embodiment of the present invention. Each GPC 208 may be configured to execute a large number of threads in parallel, where the term "thread" refers to an instance of a particular program operating on a particular set of input data. In some embodiments, single instruction, multiple data (SIMD) instruction issue techniques are employed to support parallel execution of a large number of threads without providing multiple independent instruction units. In other embodiments, single instruction, multiple thread (SIMT) techniques are employed to support parallel execution of a large number of generally synchronized threads using a common instruction unit configured to issue instructions to a group of processing units within each of the GPCs 208.Unlike a SIMD execution regime, in which processing units typically execute identical instructions, SIMT execution allows different threads to more effectively follow divergent execution paths through a given thread program. Those skilled in the art will understand that a SIMD processing regime is a functional subset of a SIMT processing regime.

[0032] The operation of the GPC 208 is advantageously controlled by a pipeline manager 305, which distributes processing tasks to data stream multiprocessors (SMs) 310. The pipeline manager 305 may also be configured to control a work distribution intersection unit 330 by specifying specific destinations by the SM 310 for processed data outputs.

[0033] In one embodiment, each GPC 208 comprises a number M of SMs 310, where M ≥ 1, wherein each SM 310 is configured to process one or more thread groups. Furthermore, each SM 310 advantageously includes an identical group of functional execution units (e.g., execution units and load-store units—referred to as exec units 302 and LSUs 303 in Fig. 3C), which may be pipelined, allowing a new instruction to be issued before a previous instruction has completed processing, as is known in the art. Any combination of functional execution units may be provided. In one embodiment, the functional units support a variety of operations, including integer or floating-point arithmetic (e.g., addition and multiplication), comparison operations, Boolean operations (AND, OR, XOR), bit shifting, and the calculation of various algebraic functions (e.g., plane interpolation, trigonometry, exponential and logarithmic functions, etc.); and the same functional unit hardware may be leveraged to perform different operations.

[0034] The series of instructions passed to a particular GPC 208 constitutes a thread, as previously defined herein, and the collection of a certain number of concurrently executing threads across the parallel processing units (not shown) within an SM 310 is referred to herein as a "bulge" or "thread group." As used herein, a "thread group" refers to a group of threads that simultaneously execute the same program on different input data, with an individual thread of the group being assigned to a different processing unit within an SM 310. A thread group may contain fewer threads than the number of processing units within the SM 310, in which case certain processing units are idle during cycles when that thread group is being processed.A thread group may also contain more threads than the number of processing units within the SM 310, in which case processing will occur over consecutive clock cycles. Since each SM 310 can handle up to G thread groups simultaneously, it follows that up to G*M thread groups can be executed in the GPC 208 at any one time.

[0035] Furthermore, multiple related thread groups (in different phases of execution) may be concurrently active within an SM 310. This collection of thread groups is referred to herein as a "cooperative thread array" ("CTA") or "thread array." The size of a particular CTA is equal to m*k, where k is the number of concurrently executing threads in a thread group and is typically an integer multiple of the number of parallel processing units within the SM 310, and m is the number of thread groups concurrently active within the SM 310. The size of a CTA is generally determined by the programmer and the amount of hardware resources, such as memory or registers, available to the CTA.

[0036] Each SM 310 contains a Level 1 (L1) cache memory (in Fig. 3C) or uses memory space in a corresponding L1 cache external to the SM 310, which is used to perform load and store operations. Each SM 310 also has access to level 2 (L2) caches shared by all GPCs 208, which can be used to exchange data between threads. Finally, the SMs 310 also have access to off-chip "global" memory, which may include, for example, the parallel processing memory 204 and / or the system memory 104. Note that any memory external to the PPU 202 may be used as global memory. Further, a level one-point-five (L1) cache may be used.5) be included in the GPC 208 and configured to receive and hold data retrieved from memory via the memory interface 214 and requested by the SM 310, including instructions, uniform data, and constant data, and to provide the requested data to the SM 310. Embodiments with multiple SMs 310 in the GPC 208 advantageously utilize common instructions and data stored in the L1.5 cache 335.

[0037] Each GPC 208 may include a memory management unit (MMU) 328 configured to map virtual addresses to physical addresses. In other embodiments, the MMU(s) 328 may be located within the memory interface 214. The MMU 328 includes a set of page table entries (PTEs) used to map a virtual address to a physical address of a tile, and optionally a cache line index. The MMU 328 may include address translation sidebar buffers (TLBs) or caches located within the multiprocessor SM 310 or the L1 cache, or the GPC 208. The physical address is processed to distribute surface data access locality, allowing efficient request interleaving between partition units 215. The cache line index can be used to determine whether a request for a cache line is a hit or a miss.

[0038] In graphics and computing applications, a GPC 208 may be configured such that each SM 310 is connected to a texture unit 315 for performing texture mapping operations, such as determining texture sample positions, fetching texture data, and filtering the texture data. Texture data is fetched from an internal texture L1 cache (not shown) or, in some embodiments, from the L1 cache within the SM 310 and retrieved from an L2 cache common to all GPCs 208, from the parallel processing memory 204, or from the system memory 104 as needed.Each SM 310 issues processed tasks to the work distribution intersection unit 330 to forward the processed task to another GPC 208 for further processing or to store the processed task in an L2 cache, in the parallel processing memory 204, or in the system memory 104 via the intersection unit 210. A pre-ROP (pre-raster operations) unit 325 is configured to receive data from the SM 310, forward data to ROP units within the partition units 215, and perform color blending optimizations, organize pixel color data, and perform address translations.

[0039] It should be noted that the core architecture described herein is illustrative and that variations and modifications are possible. Any number of processing units, such as SMs 310 or texture units 315, pre-ROP units 325, may be included in a GPC 208. As further described in Fig. As shown in Figure 2, a PPU 202 may include any number of GPCs 208, which are advantageously functionally similar to one another, so that performance does not depend on which GPC 208 receives a specific processing task. Furthermore, each GPC 208 advantageously operates independently of other GPCs 208, using separate and independent processing units and L1 cache memory to execute tasks for one or more application programs.

[0040] The expert in this field knows that the Fig. 1, Fig. 2, Fig. 3A and Fig. 3B in no way limits the scope of the present invention and that the techniques taught herein may be implemented in any suitably configured processing unit, including, without limitation, one or more CPUs, one or more multi-core CPUs, one or more PPUs 202, one or more GPCs 208, one or more graphics or special purpose processing units, etc., without departing from the scope of the present invention.

[0041] In embodiments of the present invention, it is desirable to use the PPU 202 or another processor or processors of a computer system to perform general-purpose computations using thread arrays. Each thread in the thread array is assigned a unique thread identifier ("thread ID") that can be accessed by the thread during execution of the thread. The thread ID, which can be defined as a one-dimensional or multi-dimensional numeric value, controls various aspects of the thread's processing behavior. For example, a thread ID can be used to determine which portion of the input data set should be processed by a thread and / or to determine which portion of an output data set should be generated or written by a thread.

[0042] A sequence of instructions per thread may include at least one instruction that specifies cooperative behavior between the representative thread and one or more other threads of the thread array. For example, the sequence of instructions per thread may include an instruction to suspend execution of operations for the representative thread at a specific point in the sequence until one or more of the other threads reach that specific point, an instruction for the representative thread to store data in shared memory accessible to one or more of the other threads, an instruction for the representative thread to atomically read and update data stored in shared memory accessible to one or more of the other threads based on their thread ID, or the like.The CTA program may further include an instruction to calculate an address for the shared memory from which data is to be read, where the address is a function of the thread ID. By defining appropriate functions and providing synchronization techniques, data can be written to a given memory location in shared memory by one thread of a CTA and read from that memory location by another thread of the same CTA in a predictable manner. Consequently, any desired pattern for sharing data between threads can be supported, and each thread in a CTA can share data with another thread in the same CTA.The degree, if negotiated, of data sharing between the threads of a CTA is determined by the CTA program; therefore, it should be noted that in a particular application using CTAs, the threads of a CTA may or may not share data, depending on the CTA program, and the terms "CTA" and "thread array" are used synonymously herein.

[0043] Fig. 3C is a block diagram of the SM 310 from Fig. 3B according to one embodiment of the present invention. The SM 310 includes an instruction L1 cache 370 configured to receive instructions and constants from memory via the L1.5 cache 335. A bulge scheduling and instruction unit 312 receives instructions and constants from the instruction L1 cache 370 and controls a local register file 304 and the SM 310 functional units according to the instructions and constants. The SM 310 functional units include N exec (execution or processing) units 302 and P load store units (LSU) 303.

[0044] The SM 310 provides on-chip (internal) data storage space with varying levels of accessibility. Special-purpose registers (not shown) can be read but not written by the LSU 303 and are used to store parameters that determine the "position" of each thread. In one embodiment, the special-purpose registers include a single register per thread (or per Exec unit 302 within the SM 310) that stores a thread ID; each thread ID register can only be read by a corresponding one of the Exec units 302.The special registers may further include additional registers that can be read by all threads executing the same processing tasks represented by a set of TMDs 322 (or by all LSUs 303) that store a CTA identifier, the CTA dimensions, the dimensions of a grid to which the CTA belongs (or queue position if the TMDs 322 encode a queue task instead of a grid task), and an identifier of the TMDs 322 to which the CTA is associated.

[0045] If the TMDs 322 are grid TMDs, the execution of the TMDs 322 causes a fixed number of CTAs to be started and executed to process the specified amount of data stored in the queue 525. The number of CTAs is specified as the product of the grid width, grid height, and grid depth. The specified amount of data may be stored in the TMDs 322, or the TMDs 322 may store a pointer to the data being processed by the CTAs. The TMDs 322 also store a starting address of the program being executed by the CTAs.

[0046] If the TMD 322 is a queue TMD, then a queue characteristic of the TMD 322 is used, meaning that the amount of data to be processed is not necessarily fixed. Queue entries store data for processing by the CTAs associated with the TMD 322. The queue entries may also represent a child task spawned by additional TMD 322 during the execution of a thread, thereby providing embedded parallelism. Typically, the execution of the thread or the CTA containing the thread is suspended until the execution of the child task is complete. The queue may be stored in the TMD 322 or separately from the TMD 322, in which case the TMD 322 stores a queue pointer to the queue.Advantageously, data generated by the child task can be written to the queue while the TMD 322 representing the child task is being processed. The queue can be implemented as a circular queue, so that the total amount of data is not limited by the size of the queue.

[0047] CTAs belonging to a grid have implicit parameters for grid width, height, and depth, which specify the position of the respective CTA within the grid. The special registers are written during initialization in response to commands received from the device driver 103 via the front-end area 212, and the registers do not change during the execution of a processing task. The front-end area 212 schedules each processing task for execution. Each CTA is linked to special TMDs 322 for the simultaneous execution of one or more tasks. Furthermore, a single GPC 208 can execute multiple tasks simultaneously.

[0048] A parameter memory (not shown) stores runtime parameters (constants) that can be read but not written by any thread within the same CTA (or an LSU 303). In one embodiment, the device driver 103 passes parameters to the parameter memory before instructing the SM 310 to begin executing a task that uses those parameters. Any thread within any CTA (or an Exec Unit 302 in the SM 310) can access the global memory via a memory interface 214. Portions of the global memory can be stored in the L1 cache 320.

[0049] The local register file 304 is used by each thread as work space; each register is reserved for the exclusive use of a single thread, and data in any local register file 304 is accessible only by the thread to which the register is assigned. The local register file 304 may be implemented as a register file physically or logically divided into P lanes, each having a certain number of entries (each entry capable of storing, for example, a 32-bit word). One lane is assigned to each of the N exec units 302 and each of the P load-store units LS 303, and corresponding entries in different lanes may be enriched with data for different threads executing the same program to enable SIMD execution.Different lane ranges can be assigned to different groups of the G concurrent thread groups, so that a given entry in the local register file 304 can only be accessed by a specific thread. In one embodiment, certain entries within the local register file 304 are reserved for storing thread identifiers, thereby implementing one of the special registers. Furthermore, a uniformity L1 cache 375 contains uniform or constant values ​​for each lane of the N exec units 302 and the P load / store units LS 303.

[0050] Shared memory 306 can be accessed by threads within a single CTA; in other words, each memory location in shared memory 306 is accessible to any thread within the same CTA (or any processing unit within SM 310). Shared memory 306 can be implemented as a shared register file or a shared on-chip cache with an interconnect that allows any processing unit to write to or read from any location in the shared memory. In other embodiments, a shared state space can be mapped to a per-CTA region of off-chip memory and can be cached in L1 cache 320.The parameter memory may be implemented as a special section within the same shared register file or cache that forms the shared memory 306, or may be implemented as a separate shared register file or on-chip cache to which the LSUs 303 have read-only access. In one embodiment, the area implementing the parameter memory is also used to store the CTA ID and task ID, as well as CTA and grid dimensions or queue position, thereby implementing areas of the special-purpose registers. Each LSU 303 in the SM 310 is connected to a unified address mapping unit 352, which converts an address provided for read and store instructions specified in a unified memory area into an address in each separate memory area.Consequently, an instruction can be used to access the local, shared, or global memory area by specifying an address in the unified memory area.

[0051] The L1 cache 320 in each SM 310 can be used to cache private local data per thread as well as global data per application. In some embodiments, the shared data per CTA can be cached in the L1 cache 320. The LSUs 303 are connected to the shared memory 306 and the L1 cache 320 via a memory and cache interconnect 380.

[0052] The task management unit 300 manages computational tasks to be scheduled as an array of TMD groups stored in the scheduling table 321. A TMD group is a group of computational tasks with the same scheduling priority. The number of TMD groups or priority levels can be one or more. Within each TMD group, the computational tasks are stored in a list corresponding to the respective priority level, which can be implemented with a linked list, and a linked list is assumed hereinafter. Each entry in a linked list stores a task pointer to the TMD 322 in memory and a pointer to the next entry in the respective linked list. A head pointer and a tail pointer for the linked list are stored for each TMD group. A TMD group with no tasks has a head pointer equal to the tail pointer, and an empty bit is set to TRUE.

[0053] When computation tasks are received from the parent interface 206, the task management unit 300 inserts the computation tasks into a TMD group. Specifically, a task pointer to the TMD 322 corresponding to the computation task is added to the end of the linked list for that group, unless a special TMD bit is set, which causes the task to be added to the beginning of the linked list. Although all tasks within a TMD group have the same scheduling priority level, the beginning of the linked list for the TMD group is the first computation task selected and scheduled for execution by the task management unit 300. Thus, the computation task at the beginning of the linked list has a relatively higher priority compared to other computation tasks of the same priority level.Similarly, each subsequent computation task in the linked list at the same priority level has a lower priority compared to previous computation tasks in the linked list. Therefore, task management unit 300 is able to schedule the computation tasks within a TMD group relative to each other in the entry order (assuming no tasks are specifically marked to be added to the beginning of the TMD group). Because the TMD group is specified as part of the TMD structure, the TMD group of a computation task cannot be changed while the computation task is executing. Computation tasks can also be received from processing cluster array 230.

[0054] Creating a collection of computational tasks as groups based on priority levels prior to scheduling the computational tasks allows for decoupling the rate at which computational tasks are received by the task management unit 300 from the rate at which computational tasks are issued to the work distribution unit 340 for execution. The task management unit 300 is generally capable of accepting computational tasks from one or more push buffers issued by the higher-level interface 206 at a higher rate than the computational tasks can be issued for execution by the work distribution unit 340.The inputs from the different sliding buffers are independent streams, typically generated by the same application program to have multiple groups of dependent tasks, although in some embodiments, multiple application programs may write to the sliding buffers. The task management unit 300 may be configured to cache the computation tasks in the scheduling table 321 and later select one or more computation tasks from the scheduling table 321 for output to the work distribution unit 340. By selecting the computation tasks after they have been cached, the task management unit can make the selection based on more information compared to selecting a computation task upon receiving computation tasks.For example, task management unit 300 may cache multiple lower-priority tasks received before a high-priority task. This caching enables task management unit 300 to select the high-priority task for output ahead of the lower-priority tasks.

[0055] The task management unit 300 can perform the selection for scheduling the computational tasks using a variety of different techniques: round-robin, priority, or partitioned priority scheduling. For each of the different scheduling techniques, when a computational task is selected for scheduling, the selected computational task is retrieved from the TMD group in which the selected computational task is stored. Regardless of the scheduling technique, the task management unit 300 is able to quickly select a computational task by selecting the first entry in the linked list of the appropriate group. The task management unit 300 can easily manage the computational tasks and reorder them as needed by simply changing the order of the task pointers in the linked lists of the TMD groups.Therefore, the computation tasks may be scheduled and / or executed in an order that differs from the order in which the task pointers are received by the task management unit 300 from the parent interface 206.

[0056] The simplest scheduling scheme for task management unit 300 is to schedule the computation tasks at the beginning of each group (if a computation task exists in the group) and to rotate through the groups in a circular fashion. Another scheduling technique is priority scheduling, in which the computation tasks are selected strictly in priority order. Task management unit 300 selects a computation task from the highest-priority TMD group that contains at least one computation task, starting at the beginning of the group. Multi-threaded architecture with reduced latency

[0057] Fig. 4 shows the PPU 202(0) from Fig. 2 according to an embodiment of the present invention. As in Fig. 4, the PPU 202(0) includes an I / O unit 205 that receives work (i.e., tasks) to be executed by one or more processing units of the PPU 202(0). For example, the I / O unit 205 may receive instructions related to the processing of tasks passed to the higher-level interface 206 or may receive instructions associated with memory access operations (i.e., read / write operations) passed to the memory interface 214 via the intersection unit 210. Instructions related to processing tasks may specify one or more shift buffers containing instruction streams for execution by the PPU 202(0). The higher-level interface 206 reads instructions from each of the shift buffers and sends the instruction stream stored in the shift buffer to the appropriate processing unit.For example, some commands may be related to a graphical rendering task sent to the processing cluster array 230 via a front-end unit 212 and a task / work unit 207 (not explicitly shown). Other commands may be related to data transfer tasks (i.e., copy operations) transferred to the one or more copy units 450.

[0058] Copy units 450 are configured to perform copy operations that move data from one memory location to another memory location. For example, copy unit 450(0) may receive a command specifying that a 16 MB block of memory should be copied from PP memory 204(0) to system memory 104. One type of copy command includes a source address, a destination address, and a length of data to be copied. Another type of copy command includes parameters specifying a 2D array of addresses to be copied (i.e., a copy rectangle command) from a source array to a destination array. Copy units 450 may execute concurrently with processing cluster array 230.To perform copy operations, the copy unit 450 configures the intersection unit 210 to perform memory read and write operations between the specified memory locations specified in the copy commands. Data can be copied from the DRAMs 220 into the copy unit and then sent to the destination address (e.g., from the copy unit 450 to the system memory 104), or the copy unit 450 can configure the intersection unit to send the data directly to the I / O unit 205 and send it to the system memory 104 via the communication path 113.

[0059] Conventionally, the size of a copy operation, as specified by an application, is limited by the size of the physical memory. For example, an application may send a command to PPU 202(0) specifying that a copy operation entails copying a 1 GB block of memory from PP memory 204 to system memory 104. When copy unit 450(0) processes the command, copy unit 450(0) configures intersection unit 210 to access a specific memory partition (e.g., memory partition 215(0)) for communication with the DRAM containing at least a portion of the 1 GB block of memory (e.g., DRAM 220(0)). The copy unit 450(0) then sends a memory read request to the DRAM 220(0), accessing the first 256 bits of the 1 GB block of memory.Copy unit 450(0) receives the 256 bits of data output from DRAM 220(0) in response to the memory read request. Copy unit 450(0) then configures intersection unit 210 so that copy unit 450(0) can send a write request to system memory 104 via I / O unit 205, thereby storing the 256 bits of data at the destination address. Copy unit 450(0) then configures intersection unit 210 to communicate with DRAM 220(0) and send a second memory read request to DRAM 220(0) to access the next 256 bits of the 1 GB block of memory. DRAM 220(0) outputs the next 256 bits of data to copy unit 450(0), which sends a write request containing the next 256 bits of data to system memory 104 via I / O unit 205.Copy unit 450(0) continues in this manner until the entire 1 GB block of memory has been transferred from DRAM 220(0) (or the other DRAM units if the block spans multiple DRAM units) to system memory 104. In alternative embodiments, copy unit 450(0) may configure memory interface 214 to perform direct memory transfers between DRAM 220(0) and system memory 104 by configuring I / O unit 205 and intersection unit 210 such that DRAM 220(0) can communicate directly with I / O unit 205 and send a write command to system memory 104 without direct intervention from copy unit 450(0). In other embodiments, copy units 450 have a pipelined architecture that allows multiple copy commands to be executed concurrently.For example, a first read command associated with a first copy operation may be issued to DRAM 220. While data associated with the first read command is being fetched, a second read command associated with a second copy operation may be issued to DRAM 220. In such embodiments, a higher-priority copy operation may be issued to a copy unit, which begins executing the higher-priority copy operation before the execution of a lower-priority copy operation is complete.

[0060] Note that copy operations can require a significant number of clock cycles to complete, depending on the size of the memory block to be copied. Conventional copy units do not implement preemptive capability, meaning that once a copy operation is submitted to the copy unit, the entire copy operation is executed before another copy operation can be sent to the copy unit. In other words, if a higher-priority application submits a copy operation to PPU 202(0), the higher-priority copy operation cannot be executed until the previously scheduled copy operation belonging to a lower-priority application completes. There are many ways to account for this long latency.

[0061] First, the long latency could be addressed by adding preemption capabilities to each individual processing unit of PPU 202(0) (e.g., copy unit 450(0), copy unit 450(1), GPC 208(0), etc.), allowing operations associated with higher priority applications to be prioritized over operations associated with lower priority applications. For example, preemption capabilities could be added to a processing unit by providing additional priority scheduling logic and / or context switching logic. Copy unit 450 could monitor multiple copy operations and perform higher priority copy operations over lower priority copy operations, using scheduling algorithms known to those skilled in the art.However, these hardware-level changes would increase the size and complexity of each processing unit in the PPU 202(0). Increasing size means increased cost, as well as additional power consumption and heat generated from the additional logic. Therefore, implementing preemption in each individual processing unit is undesirable.

[0062] Second, the long latency could be addressed by limiting the size of copy operations (or other processing tasks) issued to PPU 202(0) by each individual application. This approach requires the programmer to manage the size of processing tasks such that large tasks associated with long latencies are never submitted to PPU 202(0). This approach is undesirable because it adds programming complexity, requiring the application to manually schedule hundreds or thousands of separate operations rather than sending a single operation to PPU 202. Furthermore, adding additional logic to device driver 103 and / or PPU 202 may be necessary to ensure that copy operations do not exceed a threshold size that would trigger long latencies.If this logic has not been added, a programmer can simply schedule a large processing task in the PPU 202 that would not allow low-latency preemption.

[0063] The two previously described approaches are undesirable because they unnecessarily increase the complexity and size of the PPU 202(0), or because they require too much of the preemption to be implemented at the application level, which is left to the programmer for efficient operation. Therefore, the technique described herein implements a different approach that introduces a hardware preprocessor between the application and the various processing units of the PPU 202(0). The preprocessor 410 is configured to receive tasks sent to the PPU 202(0) by one or more applications and to implement preemption of high-priority tasks over lower-priority tasks.The pre-processor 410 implements pre-allocation by dividing tasks into a group of smaller subtasks such that the dispatching of each subtask can occur independently of each of the other subtasks. The size of each subtask is limited by a threshold size such that the execution of the subtask by a processing unit does not introduce a long wait before another subtask can be executed by the processing unit. In one embodiment, the pre-processor 410 includes logic for monitoring or tracking the state of a task. For example, the pre-processor 410 may include registers for storing the state of a task, such as the next memory location to be copied into the memory block associated with a copy operation. In another embodiment, the pre-processor 410 may store the state of a task in the PP memory 204.

[0064] For example, to illustrate the operation of copy units 450, a copy operation may be received from the host interface 206 as part of the command stream contained in a shift buffer. The copy operation may specify a large block of memory to be copied from the PP memory 204 to the system memory 104. In conventional systems, the host interface would decode at least a portion of the command to determine that the command should be sent to one of the available copy units, and the entire copy operation would be sent to a first copy unit. The copy unit would then execute the copy operation until the entire block of memory is copied to the system memory.

[0065] In contrast, the higher-level interface 206 is implemented from Fig. 4, a hardware pre-processor 410 that divides the copy operation into several subtasks associated with copy operations for small portions of the memory block specified by the original copy operation. For example, a copy operation may request a large 256 MB block of memory to be copied from PP memory 204 to system memory 104. The pre-processor 410 sends a copy command to the copy unit 450(0) for the first 4 KB of memory of the 256 MB memory block. The pre-processor 410 then modifies the original copy operation by incrementing the initial memory address contained in the copy command by 4 KB and stores the modified copy command until the copy unit 450(0) has completed executing the first 4 KB copy operation. The preprocessor 410 then sends the new copy command to the copy unit 450(0) for the next 4 kB of memory, and so on.However, if the higher-priority interface 206 receives another copy operation from a higher-priority application before the entire 256 MB block of memory is copied, the preprocessor 410 downgrades the lower-priority copy operation by sending a first copy command associated with the higher-priority copy operation to the copy unit 450(0) instead of sending the next subsequent copy command associated with the lower-priority copy operation. Thus, in a relatively small number of clock cycles, a higher-priority application is given priority in executing a particular task in a given processing unit because the processing unit is never assigned to the particular task for more than a maximum number of clock cycles.The latency associated with implementing preemption in this manner may be smaller than directly implementing preemption within a processing unit that executes unbounded tasks (e.g., saving context state and loading a separate context to execute the higher priority task), and it is not necessary for the programmer to manually manage preemption latency by limiting the size of tasks submitted to the PPU 202.

[0066] In some embodiments, copy operations generated by an application may specify additional operations (e.g., releasing a semaphore, triggering an interrupt, clearing a speaker, etc.) to be performed by copy unit 450 once the copy operation is complete. These additional operations may be included in the copy command sent to copy unit 450, as additional bits in the command, or may be sent as a separate command after the copy command. Pre-processor 410 may be configured to schedule the additional operations with respect to the subtasks for a given task. For example, if the additional operations are specified in the original copy operation, pre-processor 410 may configure each of the subtasks such that only the final subtask of the original task includes the additional operations.

[0067] In one embodiment, the pre-processor 410 monitors each of the pending operations in an ordered list 420 arranged according to priority. The pre-processor 410 is configured to schedule the pending operation with the highest priority. In another embodiment, the parent interface 206 includes a number of FIFOs (not shown), with each FIFO corresponding to a given priority level. As the parent interface 206 receives tasks, the tasks are added to the specific FIFO associated with that task's priority level. The pre-processor 410 then selects the next pending task in the highest priority FIFO containing at least one pending task for scheduling to the available processing unit. The pending task is divided into a group of smaller subtasks, and the subtasks are scheduled to the appropriate processing unit.

[0068] In some embodiments, the parent interface 206 operates asynchronously with the various processing units. In other words, there may be some latency between the scheduling of the task for a given processing unit by the parent interface 206 and the execution of the task in that processing unit. In such embodiments, a processing unit may queue a number of pending tasks for execution. For example, the copy unit 450(0) may include a FIFO that stores up to eight pending copy commands. Therefore, the parent interface 206 may send up to eight copy commands to the copy unit 450(0), which are executed in the order in which the copy commands are received at the copy unit 450(0).The higher-level interface 206 may also dispatch other commands or operations to other processing units, such as the processing cluster array 230, while the copy commands are being executed. Note that in some situations, it may be desirable to dispatch multiple subtasks to a given processing unit to avoid idle times or sleep periods caused by the inherent latency between scheduling and execution.

[0069] The master interface 206 may manage many tasks simultaneously for several different processing units. Each clock cycle, the master interface 206 may check a particular processing unit to determine whether that processing unit is idle (that is, whether it is available to execute a new subtask). In one embodiment, the master interface 206 and the processing units have a special interface, such as a single-wire connection, that indicates whether the processing unit is idle. In another embodiment, the master interface 206 and the processing units communicate via an existing bidirectional communication bus that enables the processing units to send a command to the master interface 206 indicating whether the processing unit is idle.In yet another embodiment, the host interface 206 and the processing units implement a credit-based scheduling interface. For example, if the copy unit 450(0) includes a FIFO for storing multiple copy instructions to be executed, the copy unit 450(0) may issue a number of credits to the host interface 206, where the number of credits represents the number of open locations in the FIFO in the copy unit 450(0). As the preprocessor 410 issues copy instructions to the copy unit 450(0), the host interface 206 decrements the number of credits, and when the copy unit 450(0) completes execution of a copy instruction previously sent to the copy unit 450(0), a new credit is sent to the host interface 206 indicating that another location is available in the FIFO.

[0070] Depending on the number of processing units in PPU 202, the processing unit may be idle for a number of clock cycles before host interface 206 can schedule the next subtask for the processing unit. Therefore, in one embodiment, preprocessor 410 is configured to ensure that two or more subtasks are waiting for execution by a given processing unit whenever there are at least two subtasks ready for execution. For example, a copy unit 450(0) may include a FIFO that stores up to 8 copy instructions queued for subsequent execution. Upon idleness of copy unit 450(0), it may then execute the next copy instruction from the FIFO without having to wait for host interface 206 to issue a new instruction.Without this implementation, the copy unit 450(0) may waste many cycles simply communicating the idle state to the higher-level interface 206 and waiting for the preprocessor 410 to issue the next copy command. The FIFO in the copy unit 450(0) enables more efficient execution, allowing the copy unit 450(0) to begin processing the next subtask while the preprocessor 410 determines which subtask should be sent to the copy unit 450(0) next and whether the currently executing operation should be deprioritized relative to a higher-priority application. In one embodiment, a programmable register sets the number of subtasks pending in the processing unit at a given time.For example, the register may indicate that four subtasks should be queued for execution by the processing unit at a given time. Based on the value in the register, the preprocessor 410 may send a given number of copy instructions to the copy unit 450(0), which are stored in the FIFO. As each copy instruction completes, the preprocessor 410 sends a new copy instruction to the copy unit 450(0) so that the FIFO holds approximately the predetermined number of pending copy instructions ready for execution at a given time. In other words, the value of the register establishes a threshold number of open subtasks queued for execution by a processing unit. The processing unit is considered available when the number of open subtasks in the processing unit is less than the threshold number of open subtasks.The threshold number of open subtasks can be set to ensure that preemption of a given task is completed in a maximum number of clock cycles (i.e., since the maximum size and maximum number of open subtasks dictate a maximum time before a processing unit will be idle).

[0071] As previously in connection with Fig. 4, the preprocessor 410 divides tasks into a group of smaller subtasks such that subtasks can be sent to a processing unit without reserving that processing unit to complete the entire task before preempting it for another task from a higher-priority application. In one embodiment, the preprocessor 410 simply divides the tasks based on a threshold size for each subtask. However, in other embodiments, the preprocessor 410 may be configured to consider other criteria for dividing tasks.

[0072] Fig. 5A and Fig. 5B show two approaches for dividing a task into a group of subtasks according to an embodiment of the present invention. As in Fig. 5A, a copy operation may specify that copy unit 450(0) should copy a memory block 510 from PP memory 204 to system memory 104. The instruction specifying the copy operation may include a starting address for memory block 510 in PP memory 204 (e.g., 0x07005800), a starting address for the destination memory block in system memory 104, and a length associated with the memory block (e.g., 24064 bytes). As shown, each unique memory address is a 32-bit address referencing a single byte of memory, but other addressing architectures are also contemplated as being within the scope of the present invention, such as 64-bit addressing, or where each 32-bit address designates 4 bytes (i.e., 32 bits) of memory.

[0073] In one embodiment, pre-processor 410 is configured to divide the copy operation into a group of smaller copy operations that perform a data copy operation of less than or equal to a threshold, such as 4 KB (i.e., 4096 bytes). For example, a system 100 may implement a unified virtual memory architecture using 4 KB pages. Performing data copy operations on 4 KB pages or smaller is more efficient because the latency for a 4 KB copy operation to complete is not unacceptably long and the data from the copy operation is contained in a single memory page, assuming the operation is page-by-page. In addition to limiting each subtask to copy operations of less than or equal to the threshold, processor 410 is configured to align the copy operations to physical memory boundaries.Proper memory alignment allows for more efficient memory accesses. For example, a GDDR5 SDRAM (Double Data Rate Synchronous Dynamic Graphics Random Access Memory) implements a 32-bit data bus with an 8n prefetch architecture, allowing 256 bits (i.e., 32 bytes) to be read or written per memory access request. However, to read 256 bits in a single memory request to the GDDR5 DRAM, the 256 bits must be aligned to 32-byte boundaries.

[0074] As in Fig. As shown in Figure 5A, a first subtask 511 has a starting address at 0x07005800 that is aligned to a 32-byte boundary (that is, in binary terms, the five least significant bits of the memory address are zeros). However, the starting address of the first subtask 511 is not aligned to a 4-KB memory boundary (e.g., a page boundary). Therefore, the preprocessor 410 generates a copy instruction for the first subtask 511 that includes a starting address of the first subtask 511, a destination address for the first subtask (equal to the destination address for the original copy operation), and a length of 2 KB, which is the difference between the starting address of the first subtask 511 and the nearest 4-KB memory boundary.The preprocessor 410 then sends the copy instruction for the first subtask 511 to the copy unit 450(0) for execution and modifies the original copy operation by incrementing the source address and the destination address by the length of the first subtask 511 (i.e., 2 kB) and by decreasing the length of the original copy operation, which represents the remaining memory block to be copied as part of the original copy operation.

[0075] When copy unit 450(0) is ready to execute another copy instruction (that is, copy unit 450(0) is idle or contains empty time slots or locations in a FIFO for pending instructions), pre-processor 410 generates another copy instruction for the next subtask of the modified copy operation. Pre-processor 410 generates a copy instruction for the second subtask 512 that includes a start address of the second subtask 512 (i.e., 0x07006000), a destination address for the second subtask, and a length. Since the remaining copy operation belongs to a memory block longer than the 4 KB threshold, pre-processor 410 sets the length of the second subtask to 4 KB. The copy command for the second subtask 512 is sent to the copy unit 450(0), and the modified copy operation is again modified by changing the source address and the destination address by the length of the first subtask 512 (ie4 kB) and the length of the modified copy operation is reduced.

[0076] The preprocessor 410 continues to issue copy commands to the copy unit 450(0) related to the additional subtasks (i.e., subtasks 513, 514, 515, 516, and 517). The last subtask 517 corresponds to a copy operation for a memory block with less than the 4-kB threshold size. Therefore, as shown in Fig. 5A, the copy instruction for the final subtask 517 has a length of 1536 bytes, representing the remaining memory to be copied as part of the original copy operation.

[0077] Note that during the process of dividing the original task into the group of subtasks, the parent interface 206 may receive another task from a higher-priority application. For example, after the preprocessor 410 sends the copy command associated with the second subtask 512, the parent interface 206 may receive a new task from a higher-priority application. The new task from the higher-priority application may be a copy operation for a different memory block.Because the new task has a higher priority than the original task, the pre-processor 410 divides the new task into a group of subtasks, and instead of sending a copy command associated with the third subtask 513 to the copy unit 450(0), the pre-processor 410 sends a copy command associated with the first subtask of the new task to the copy unit 450(0). The pre-processor 410 can then send subsequent copy commands associated with other subtasks of the new task until the new task is fully executed. Once the copy unit 450(0) is available, the pre-processor 410 sends the third subtask 513 of the original copy operation to the copy unit 450(0).The preprocessor 410 then completes sending copy commands related to the remaining subtask of the original copy operation to the copy unit 450(0) until the entire copy operation is completely executed.

[0078] In a further embodiment, as in Fig. As shown in Figure 5B, certain types of memory copy operations are performed on a rectangle (i.e., a 2D memory array arranged in rows and columns). Each rectangle can be specified by a starting memory location (i.e., the upper-left memory address in the rectangle), as well as by a horizontal dimension and a vertical dimension (e.g., as a number of distinguishable memory addresses or bytes). Accessing memory addresses in this manner can be efficient because a specific memory row address or column address can be retrieved for multiple consecutive memory locations, and the column address or row address can be incremented accordingly to retrieve subsequent data more efficiently (i.e., without changing the row address or column address).For example, a rectangle 520 represents a copy operation for a memory block that has 272 bytes in the horizontal dimension and 160 bytes in the vertical dimension.

[0079] For rectangle 520, preprocessor 410 divides the copy operation into multiple subtasks (i.e., 521, 522, etc.), each corresponding to a copy operation for a smaller memory rectangle. For example, in this embodiment, the maximum size rectangle that can be copied may have a width of 64 addresses (i.e., horizontally) and a height of 64 addresses (i.e., vertically). The total size of the threshold rectangle is 4 KB. First, preprocessor 410 would subdivide the rectangle into smaller rectangles of 64 rows or fewer (e.g., subtasks 521 through 525, subtasks 526 through 530, and subtasks 531 through 535). Thereafter, the smaller rectangles are further subdivided into subtasks corresponding to rectangles less than or equal to the threshold size. The subtasks may also be aligned to specific memory boundaries.For example, the first subtask 521 corresponds to a copy rectangle instruction with a width of 48 addresses and a height of 64 addresses (to be aligned to a 64-byte boundary), the second subtask 522 corresponds to a copy rectangle instruction with a width of 64 addresses and a height of 64 addresses, etc. Since the horizontal dimension of the original copy rectangle instruction was not aligned to a 64-byte boundary, the fifth subtask 525 corresponds to a copy rectangle instruction with a width of 32 addresses and a height of 64 addresses. For example, a block buffer in the PP memory 204 may be implemented as a 2D array of memory addresses, with each 4-kB block storing data for a 16 × 16 pixel tile of the block buffer, where each pixel comprises 16 bytes of data (e.g., 32 bits per channel RGBA).

[0080] Note that various copy operations previously specified can be implemented in a virtual memory architecture. For example, rectangle 520 may represent a data structure in virtual memory, where each aligned sub-rectangle (e.g., subtask 521, 522, etc.) corresponds to a different virtual memory page, and therefore the original copy-rectangle operation is not necessarily linked to adjacent memory blocks in physical memory (although each tile, for example, is stored in a 4-kB block of adjacent physical memory locations).

[0081] Fig. Figure 6 is a flowchart of method steps for increasing efficiency in multi-threaded processing units according to an embodiment of the present invention. Although the method steps are described in connection with the systems of Fig.1-5, one skilled in the art will recognize that any system configured to perform the method steps in any order is within the scope of the present invention.

[0082] As shown, a method 600 begins in step 602, in which the master interface 206 receives a first task to be executed by a processing unit. In one embodiment, a pre-processor 410 in the master interface 206 reads instructions from one or more shift buffers. The instructions may include copy operations (i.e., a task) to be sent to a copy unit 450(0). For example, the first task may be a copy operation that, when executed by the copy unit 450(0), causes the copy unit 450(0) to transfer data from a first memory location to a second memory location. In step 604, the master interface 206 divides the first task into a first group of subtasks.In one embodiment, the pre-processor 410 generates a new group of copy instructions that, when executed by the copy unit 450(0), cause the copy unit 450(0) to move portions of the data associated with the original copy operation to portions of the second memory location. In step 606, the parent interface 206 issues at least one subtask in the first group of subtasks to the processing unit. In one embodiment, the pre-processor 410 sends a first subtask (i.e., a copy instruction) associated with the first task to the copy unit 450(0). The copy unit 450(0) executes the first subtask, thereby copying a first portion of the memory block associated with the original copy operation. Additional subtasks (i.e., copy instructions) are issued to the copy unit 450(0) when the copy unit 450(0) becomes available.In one embodiment, the higher-level interface 206 issues a single subtask to the processing unit per unit of time. In another embodiment, the processing unit may include a queue or FIFO so that the higher-level interface 206 can issue two or more subtasks to the processing unit simultaneously.

[0083] In step 608, before the parent interface 206 has finished executing each subtask associated with the first task, thereby completing the original task, the parent interface 206 receives a second task to be executed by the processing unit, the second task belonging to an application with a higher priority than the first task. In step 610, the parent interface 206 divides the second task into a second group of subtasks. In step 612, in order to downgrade the execution of the first task in the processing unit, the parent interface 206 issues at least one subtask from the second group of subtasks to the processing unit before all subtasks of the first group of subtasks are issued to the processing unit.For example, after sending multiple copy commands to copy unit 450(0) associated with a first copy operation from the shift buffer, parent interface 206 issues multiple copy commands to copy unit 450(0) associated with a second, higher-priority copy operation to the processing unit. After each copy command associated with the second, higher-priority copy operation completes execution in copy unit 450(0), parent interface 206 may continue transmitting remaining copy commands associated with the first copy operation to copy unit 450(0).

[0084] It should be noted that the scope of the present invention is not limited to copy instructions and the copy units 450 of a parallel processing unit (GPU) 202, and that various types of processing units may implement preemption techniques using an intermediate hardware unit, such as the preprocessor 410. For example, the GPCs 208 perform graphics tasks, such as executing vertex shading (i.e., graphics program) on a group of vertices. The preprocessor 410 may implement an algorithm for receiving a group of vertices that define two or more primitives (i.e., triangles, squares, strips of triangles, a mesh, etc.) defined in a 3D model and breaking the mesh into a group of smaller meshes that may be passed to the GPCs 208.The preprocessor 410 could be implemented to add preemption properties for each type of processing unit that receives an input that can be divided into smaller subtasks.

[0085] In summary, a multi-threaded processing unit can implement preemption techniques in one or more processing units (e.g., copy units, GPCs, etc.) by providing an intermediate hardware unit to divide two or more tasks into smaller subtasks and to schedule subtasks for the two or more tasks based on the priority of the task. By limiting the size of the subtasks, the waiting time before the processing unit can be used to execute a higher-priority task can be controlled to ensure that the higher-priority task is executed quickly and efficiently.

[0086] An advantage of the disclosed technique is that context switching is unnecessary in each individual processing unit, and therefore the processing units are not implemented with complex scheduling logic and / or context switching features. Applications can be preempted or prioritized by simply allowing smaller tasks to complete their execution and then switching to the higher-priority task. Furthermore, the technique is completely transparent to a programmer, who can create tasks of any size without having to worry about the latency introduced into the system that would prevent higher-priority tasks from executing.

[0087] The invention has been described with reference to specific embodiments. However, those skilled in the art will recognize that various modifications and changes may be made thereto without departing from the broader spirit and scope of the invention as set forth in the appended claims. The foregoing description and drawings are therefore to be considered as illustrative and not in a limiting sense.

[0088] Therefore, the scope of the embodiments of the present invention is defined by the following claims.

Claims

[1] A computer-implemented method for increasing efficiency in multi-threaded processing units of a computing device having a preprocessor (410), a copy unit, and a processor cluster array (230), the method comprising: Receiving a first task to be performed by a copying unit; Dividing, by the preprocessor, the first task into a first group of subtasks, each subtask in the first group of subtasks being smaller than a threshold size and to be executed by the copy unit; Outputting at least one subtask from the first group of subtasks to the copying unit for execution; Receiving a second task to be executed by the copying unit, the second task having a higher priority than the first task; dividing, by the preprocessor, the second task into a second group of subtasks, each subtask in the second group of subtasks being smaller than the threshold size and to be executed by the copy unit; treating the first task subordinately by issuing at least one subtask from the second group of subtasks to the copying unit for execution before all subtasks from the first group of subtasks are issued to the copying unit for execution; and Outputting at least one further subtask from the first group of subtasks to the copying unit for execution after the at least one subtask from the second group of subtasks has been output to the copying unit. [2] The method of claim 1, wherein the first task comprises a copy operation. [3] The method of claim 2, wherein dividing the first task into the first group of subtasks comprises: dividing an initial memory block specified by the copy operation into two or more submemory blocks, and generating two or more copy instructions for execution by the copy unit corresponding to the two or more submemory blocks. [4] The method of claim 3, wherein the partial memory blocks are aligned on a memory boundary. [5] The method of claim 3, wherein the copy operation comprises a copy rectangle operation and wherein the partial memory blocks comprise two-dimensional memory arrays. [6] The method of claim 1, wherein the first task comprises a graphics operation associated with a plurality of primitives, and wherein the subtasks in the first group of subtasks comprise at least two graphics operations associated with different subsets of primitives belonging to the plurality of primitives. [7] The method of claim 1, further comprising: monitoring the first task and the second task in an ordered list based on a priority. [8] The method of claim 1, wherein dividing the first task into the first group of subtasks comprises: Generating a first subtask that is less than or equal to the threshold size based on the first task; modifying the first task to produce a modified first task; Monitoring the copy unit to determine when the copy unit is available for further processing; and if the copy unit is available, generating a second subtask that is less than or equal to the threshold size based on the modified first task, wherein the copy unit is available for further processing if a number of open subtasks in the copy unit is less than a threshold number of open subtasks. [9] The method of claim 1, further comprising: sending two or more subtasks to the copy unit to be queued for execution. [10] A computing device (202) for increasing efficiency in multi-threaded processing units, the device comprising: a copying unit trained to perform tasks; a processor cluster array, and a preprocessor connected to the copying unit and configured to: to receive a first task to be performed by a copy unit, to divide the first task into a first group of subtasks to be executed by the copying unit, each subtask in the first group of subtasks being smaller than a threshold size, output at least one subtask from the first group of subtasks to the copying unit for processing, to receive a second task to be executed by the copying unit, the second task having a higher priority than the first task, to divide the second task into a second group of subtasks to be executed by the copying unit, each subtask in the second group of subtasks being smaller than the threshold size, to treat the first task subordinately by outputting at least one subtask from the second group of subtasks to the copying unit for processing before all subtasks from the first group of subtasks are output to the copying unit for processing, and output at least one additional subtask from the first group of subtasks to the copying unit for processing after the at least one subtask from the second group of subtasks has been output to the copying unit.

Citation Information

Patent Citations

  • Dynamic Bandwidth Determination and Processing Task Assignment for Video Data Processing

    US20110292057A1

  • Process for controlling technological operations or processes

    US6260058B1

  • Hardware resource based mapping of cooperative thread arrays (CTA) to result matrix tiles for efficient matrix multiplication in computing system comprising plurality of multiprocessors

    US7506134B1