# US 2015/0145871 A1 · System, method, and computer program product to enable the yielding of threads in a graphics processing unit to transfer control to a host processor

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2015/0145871 A1
- Document ID: US20150145871A1
- Status: Published application
- Kind: A1
- Application number: 14/088,289
- Filed: 2013-11-22
- Published: 2015-05-28
- Earliest claimed: 2013-11-22
- Assignees: NVIDIA Corporation
- Applicants: NVIDIA Corporation
- Inventors: Steven Parker; Andreas Dietrich
- Web page: https://patentgrep.com/patent/US20150145871A1

## CPC

- G06T 1/20: Processor architectures; Processor configuration, e.g. pipelining
- G06F 8/41: Compilation
- G06F 8/447: {Target code generation}
- G06F 9/45516: {Runtime code conversion or optimisation}
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method, system, and computer-program product are provided to enable the yielding by threads executing in a processing unit to transfer control to a host processor. The method includes the steps of receiving an intermediate representation of a program, replacing a yield instruction in the intermediate representation with a yield operation that includes one or more instructions, and compiling at least a portion of the modified intermediate representation into a machine code for execution on a parallel processing unit.

## Claims

### Claim 1

A method, comprising:
receiving an intermediate representation of a program;
replacing a yield instruction in the intermediate representation with a yield operation that includes one or more instructions; and
compiling at least a portion of the modified intermediate representation into a machine code for execution on a parallel processing unit.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
determining that the modified intermediate representation can be split into two or more sections, wherein the at least a portion of the modified intermediate representation comprises a first section of the two or more sections; and
compiling at least a second portion of the modified intermediate representation into a second machine code for execution on the parallel processing unit.

### Claim 3 (depends on 1)

The method of claim 1, further comprising generating a control-flow graph associated with the intermediate representation of the program.

### Claim 4 (depends on 1)

The method of claim 1, wherein the intermediate representation is represented using a Parallel Thread Execution (PTX) instruction set architecture.

### Claim 5 (depends on 1)

The method of claim 1, wherein the intermediate representation is represented using a Low Level Virtual Machine (LLVM) compiler infrastructure.

### Claim 6 (depends on 1)

The method of claim 1, wherein the yield operation includes a first set of instructions that cause the parallel processing unit to save state information associated with a thread block to a data structure in a memory and terminate execution of the thread block to transfer control back to a host processor.

### Claim 7 (depends on 6)

The method of claim 6, wherein the yield operation includes a second set of instructions that cause the parallel processing unit to restore the state information associated with the thread block to one or more registers in the parallel processing unit.

### Claim 8 (depends on 7)

The method of claim 7, wherein a first instruction in the second set of instructions is specified as a continuation point and an address that points to the first instruction is stored with the state information in the data structure.

### Claim 9 (depends on 1)

The method of claim 1, further comprising:
copying the machine code to a memory associated with the parallel processing unit; and
transmitting a command to the parallel processing unit that causes the parallel processing unit to launch one or more thread blocks that are configured to execute the machine code.

### Claim 10 (depends on 9)

The method of claim 9, further comprising:
determining that the parallel processing unit has completed execution of each of the one or more thread blocks;
performing additional work via a host processor; and
transmitting a second command to the parallel processing unit that causes the parallel processing unit to re-launch the one or more thread blocks to execute the machine code from a continuation point.

### Claim 11 (depends on 1)

The method of claim 1, further comprising compiling a high-level shading language version of the program into the intermediate representation.

### Claim 12 (depends on 11)

The method of claim 11, wherein the high-level shading language is Cg (C for graphics).

### Claim 13 (depends on 1)

The method of claim 1, further comprising modifying the intermediate representation of the program to include one or more yield instructions.

### Claim 14 (depends on 1)

The method of claim 1, wherein the yield instruction is a single, unique semantic that represents a point in the program where the parallel processing unit stops execution of a thread block and yields control back to a host processor.

### Claim 15

A computer-readable storage medium storing instructions that, when executed by a processor, causes the processor to perform steps comprising:
receiving an intermediate representation of a program;
replacing a yield instruction in the intermediate representation with a yield operation that includes one or more instructions; and
compiling at least a portion of the modified intermediate representation into a machine code for execution on a parallel processing unit.

### Claim 16 (depends on 15)

The computer-readable medium of claim 15, the steps further comprising:
determining that the modified intermediate representation can be split into two or more sections, wherein the at least a portion of the modified intermediate representation comprises a first section of the two or more sections; and
compiling at least a second portion of the modified intermediate representation into a second machine code for execution on the parallel processing unit

### Claim 17 (depends on 15)

The computer-readable medium of claim 15, wherein the yield operation includes a first set of instructions that cause the parallel processing unit to save state information associated with a thread block to a data structure in a memory and terminate execution of the thread block to transfer control back to a host processor.

### Claim 18

A system, comprising:
A parallel processing unit; and
a host processor, coupled to the parallel processing unit, that executes a compiler configured to:
receive an intermediate representation of a program,
replace a yield instruction in the intermediate representation with a yield operation that includes one or more instructions, and
compile at least a portion of the modified intermediate representation into a machine code for execution on the parallel processing unit.

### Claim 19 (depends on 18)

The system of claim 18, further comprising a memory associated with the parallel processing unit, the compiler further configured to:
copy the machine code to the memory, and
transmit a command to the parallel processing unit that causes the parallel processing unit to launch one or more thread blocks that are configured to execute the machine code.

### Claim 20 (depends on 18)

The system of claim 18, wherein the yield operation includes a first set of instructions that cause the parallel processing unit to save state information associated with a thread block to a data structure in a memory and terminate execution of the thread block to transfer control back to the host processor.
