# US 11,120,602 B2 · Acceleration of shader programs by compiler precision selection

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

- Number: US 11,120,602 B2
- Document ID: US11120602B2
- Status: Granted
- Kind: B2
- Application number: 16/429,989
- Filed: 2019-06-03
- Published: 2020-12-03
- Granted: 2021-09-14
- Earliest claimed: 2019-06-03
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Ivan Nevraev; Vishal Chandra Sharma
- Web page: https://patentgrep.com/patent/US11120602B2

## CPC

- G06T 15/005: {General purpose rendering architectures}
- G06F 8/41: Compilation
- G06F 8/51: Source to source
- G06T 1/20: Processor architectures; Processor configuration, e.g. pipelining
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Methods and devices for lowering precision of computations used in shader programs may include receiving program code for a shader program to use with a graphics processing unit (GPU) that supports half precision storage and arithmetic in shader programs. The methods and devices may include performing at least one pass on the program code to select a set of operations within the program code to lower a precision of a plurality of computations used by the set of operations and evaluating a risk of precision loss for lowering the precision to a half precision for each computation of the plurality of computations. The methods and devices may include generating edited program code by rewriting the computation to the half precision in response to the risk of precision loss being a precision loss threshold.

## Claims

### Claim 1

A computer device, comprising:
a graphics processing unit (GPU) that supports half precision storage and arithmetic in shader programs;
a memory to store data and instructions;
at least one processor configured to communicate with the memory;
a compiler in communication with the memory and the at least one processor, wherein the compiler is operable to:
receive program code for a shader program to use with the GPU;
perform at least one pass on the program code to automatically analyze a structure of the program code and select a set of operations within the program code to lower a precision of a plurality of computations used by the set of operations in response to the analysis identifying the set of operations as supporting half precision, wherein the analysis is a trained search that uses hardware information in combination with a list of previously defined operations that support half precisions and a list of previously defined operations sensitive to precision lowering for identifying the set of operations as supporting half precision;
evaluate a risk of precision loss for lowering the precision for a computation to a half precision for each computation of the plurality of computations;
generate edited program code by rewriting the computation to the half precision in response to the risk of precision loss being below a precision loss threshold;
provide a notification with a warning for possible precision loss in response to the risk of precision loss being above the precision loss threshold; and
generate a report with information of changes made to precision in the edited program code, wherein the report identifies one or more computations in the edited program where the precision was lowered and provides information on decisions to maintain the precision for other computations in the edited program code.

### Claim 2 (depends on 1)

The computer device of claim 1, wherein the precision loss threshold identifies whether the computation supports the half precision.

### Claim 3 (depends on 1)

The computer device of claim 1, wherein the set of operations are selected in response to being previously identified as supporting half precision or in response to user input.

### Claim 4 (depends on 1)

The computer device of claim 1, wherein hardware parameters of the GPU are used by the compiler to evaluate the risk of precision loss.

### Claim 5 (depends on 1)

The computer device of claim 1, wherein the risk of precision loss is above the precision loss threshold where the computation does not support the half precision.

### Claim 6 (depends on 1)

The computer device of claim 1, wherein the risk of precision loss is below the precision loss threshold where the computation supports the half precision.

### Claim 7 (depends on 1)

The computer device of claim 1, wherein the compiler is further operable to perform an iterative process in determining whether to lower the precision of the plurality of computations within the set of operations.

### Claim 8 (depends on 1)

The computer device of claim 1, wherein the report identifies changes made to the precision of the computation and provides an explanation of the changes made.

### Claim 9 (depends on 1)

The computer device of claim 1, wherein the compiler is further operable to:
provide the edited program code to the GPU for processing into an output to present on a display; and
provide the notification to a user interface on the display.

### Claim 10

A method for lowering precision of computations used in shader programs, comprising:
receiving, at a compiler on a computer device, program code for a shader program to use with a graphics processing unit (GPU) that supports half precision storage and arithmetic in the shader programs;
performing at least one pass on the program code to automatically analyze a structure of the program code and select a set of operations within the program code to lower a precision of a plurality of computations used by the set of operations in response to the analysis identifying the set of operations as supporting half precision, wherein the analysis is a trained search that uses hardware information in combination with a list of previously defined operations that support half precisions and a list of previously defined operations sensitive to precision lowering for identifying the set of operations as supporting half precision;
evaluating a risk of precision loss for lowering the precision for a computation to a half precision for each computation of the plurality of computations;
generating edited program code by rewriting the computation to the half precision in response to the risk of precision loss being below a precision loss threshold;
providing a notification with a warning for precision loss in response to the risk of precision loss being above the precision loss threshold; and
generate a report with information of changes made to precision in the edited program code, wherein the report identifies one or more computations in the edited program where the precision was lowered and provides information on decisions to maintain the precision for other computations in the edited program code.

### Claim 11 (depends on 10)

The method of claim 10, wherein the precision loss threshold identifies whether the computation supports the half precision.

### Claim 12 (depends on 10)

The method of claim 10, wherein the set of operations are selected in response to being previously identified as supporting half precision or in response to user input.

### Claim 13 (depends on 10)

The method of claim 10, wherein hardware parameters of the GPU are used by the compiler to evaluate the risk of precision loss.

### Claim 14 (depends on 10)

The method of claim 10, wherein the risk of precision loss is above the precision loss threshold where the computation does not support the half precision.

### Claim 15 (depends on 10)

The method of claim 10, wherein the risk of precision loss is below the precision loss threshold where the computation supports the half precision.

### Claim 16 (depends on 10)

The method of claim 10, further comprising:
performing an iterative process in determining whether to lower the precision of the plurality of computations within the set of operations.

### Claim 17 (depends on 10)

The method of claim 10, wherein the report identifies changes made to the precision of the computation and provides an explanation of the changes made.

### Claim 18 (depends on 10)

The method of claim 10, wherein the method further comprises:
adjusting a level of analysis on the program code in response user input.

### Claim 19 (depends on 10)

The method of claim 10, wherein the method further comprises:
providing the edited program code to the GPU for processing into an output to present on a display; and
providing the notification to a user interface on the display.

### Claim 20

A non-transitory computer-readable medium storing instructions executable by a computer device, comprising:
at least one instruction for causing the computer device to receive program code for a shader program to use with a graphics processing unit (GPU) that supports half precision storage and arithmetic in shader programs;
at least one instruction for causing the computer device to perform at least one pass on the program code to automatically analyze a structure of the program code and select a set of operations within the program code to lower a precision of a plurality of computations used by the set of operations in response to the analysis identifying the set of operations as supporting half precision, wherein the analysis is a trained search that uses hardware information in combination with a list of previously defined operations that support half precisions and a list of previously defined operations sensitive to precision lowering for identifying the set of operations as supporting half precision;
at least one instruction for causing the computer device to evaluate a risk of precision loss for lowering the precision for a computation to a half precision for each computation of the plurality of computations;
at least one instruction for causing the computer device to generate edited program code by rewriting the computation to the half precision in response to the risk of precision loss being below a precision loss threshold;
at least one instruction for causing the computer device to provide a notification with a warning for precision loss in response to the risk of precision loss being above the precision loss threshold; and
at least one instruction for causing the computer device to generate a report with information of changes made to precision in the edited program code, wherein the report identifies one or more computations in the edited program where the precision was lowered and provides information on decisions to maintain the precision for other computations in the edited program code.
