# US 10,372,431 B2 · Unified intermediate representation

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

- Number: US 10,372,431 B2
- Document ID: US10372431B2
- Status: Granted
- Kind: B2
- Application number: 15/636,200
- Filed: 2017-06-28
- Published: 2017-10-26
- Granted: 2019-08-06
- Earliest claimed: 2014-05-30
- Assignees: Apple Inc.
- Applicants: Apple Inc.
- Inventors: Aaftab Munshi; Rahul U. Joshi; Mon P. Wang; Kelvin C. Chiu
- Web page: https://patentgrep.com/patent/US10372431B2

## CPC

- G06F 8/47: {Retargetable compilers}
- G06F 8/41: Compilation
- G06F 8/44: {Encoding}
- G06F 8/456: {Parallelism detection}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A system decouples the source code language from the eventual execution environment by compiling the source code language into a unified intermediate representation that conforms to a language model allowing both parallel graphical operations and parallel general-purpose computational operations. The intermediate representation may then be distributed to end-user computers, where an embedded compiler can compile the intermediate representation into an executable binary targeted for the CPUs and GPUs available in that end-user device. The intermediate representation is sufficient to define both graphics and non-graphics compute kernels and shaders. At install-time or later, the intermediate representation file may be compiled for the specific target hardware of the given end-user computing system. The CPU or other host device in the given computing system may compile the intermediate representation file to generate an instruction set architecture binary for the hardware target, such as a GPU, within the system.

## Claims

### Claim 1

A non-transitory machine-readable medium, on which are stored instructions, comprising instructions that when executed cause a machine to:
receive a pre-compiled library, wherein the pre-compiled library is a post-compilation intermediate representation of code, the intermediate representation of code being suitable for a subsequent compilation into machine language for a plurality of different processing devices, and wherein the pre-compiled library comprises both graphics operations and non-graphics operations;
compile at least a portion of the pre-compiled library from the intermediate representation into a first binary file comprising both one or more kernels and one or more shaders that are directly executable by a first target processor;
compile at least a portion of the pre-compiled library from the intermediate representation into a second binary file comprising both one or more kernels and one or more shaders that are directly executable by a second target processor, which is different from the first target processor,
wherein at least a first kernel from the first binary file and at least a second kernel from the second binary file are each based upon the compilation of a same first portion of the pre-compiled library, and wherein at least a first shader from the first binary file and at least a second shader from the second binary file are each based upon the compilation of a same second portion of the pre-compiled library;
responsive to detecting a request for the first kernel, retrieve the first kernel from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second kernel, retrieve the second kernel from the second binary file for execution by the second target processor.

### Claim 2 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the first target processor and the second target processor.

### Claim 3 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the source code from which the intermediate representation of code was pre-compiled.

### Claim 4 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein the instructions further cause the machine to:
responsive to detecting a request for the first shader, retrieve the first shader from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second shader, retrieve the second shader from the second binary file for execution by the second target processor.

### Claim 5 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein the instructions further cause the machine to provide the first kernel to the first target processor for execution and to provide the second kernel to the second target processor for execution.

### Claim 6 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein:
a first compiler is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the first binary file; and
a second complier is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the second binary file.

### Claim 7 (depends on 1)

The non-transitory machine-readable medium of claim 1, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model contains functions for performing parallel graphics operations and functions for performing parallel non-graphics operations.

### Claim 8

A method comprising:
receiving a pre-compiled library, wherein the pre-compiled library is a post-compilation intermediate representation of code, the intermediate representation of code being suitable for a subsequent compilation into machine language for a plurality of different processing devices, and wherein the pre-compiled library comprises both graphics operations and non-graphics operations;
compiling at least a portion of the pre-compiled library from the intermediate representation into a first binary file comprising both one or more kernels and one or more shaders that are directly executable by a first target processor;
compiling at least a portion of the pre-compiled library from the intermediate representation into a second binary file comprising both one or more kernels and one or more shaders that are directly executable by a second target processor, which is different from the first target processor,
wherein at least a first kernel from the first binary file and at least a second kernel from the second binary file are each based upon the compilation of a same first portion of the pre-compiled library, wherein at least a first shader from the first binary file and at least a second shader from the second binary file are each based upon the compilation of a same second portion of the pre-compiled library;
responsive to detecting a request for the first kernel, retrieving the first kernel from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second kernel, retrieving the second kernel from the second binary file for execution by the second target processor.

### Claim 9 (depends on 8)

The method of claim 8, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the first target processor and the second target processor.

### Claim 10 (depends on 8)

The method of claim 8, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the source code from which the intermediate representation of code was pre-compiled.

### Claim 11 (depends on 8)

The method of claim 8, further comprising:
responsive to detecting a request for the first shader, retrieving the first shader from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second shader, retrieving the second shader from the second binary file for execution by the second target processor.

### Claim 12 (depends on 8)

The method of claim 8, wherein:
a first compiler is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the first binary file; and
a second complier is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the second binary file.

### Claim 13 (depends on 8)

The method of claim 8, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model contains functions for performing parallel graphics operations and functions for performing parallel non-graphics operations.

### Claim 14

A system for processing graphics comprising:
a CPU;
a memory associated with the CPU for holding instructions for the CPU;
a first target GPU and a second target GPU for producing graphics, wherein the instructions for the CPU, when executed cause the production of graphics by:
receiving a pre-compiled library, wherein the pre-compiled library is a post-compilation intermediate representation of code, the intermediate representation of code being suitable for a subsequent compilation into machine language for a plurality of different processing devices, and wherein the pre-compiled library comprises both graphics operations and non-graphics operations;
compiling at least a portion of the pre-compiled library from the intermediate representation into a first binary file comprising both one or more kernels and one or more shaders that are directly executable by a first target processor;
compiling at least a portion of the pre-compiled library from the intermediate representation into a second binary file comprising both one or more kernels and one or more shaders that are directly executable by a second target processor, which is different from the first target processor,
wherein at least a first kernel from the first binary file and at least a second kernel from the second binary file are each based upon the compilation of a same first portion of the pre-compiled library, wherein at least a first shader from the first binary file and at least a second shader from the second binary file are each based upon the compilation of a same second portion of the pre-compiled library;
responsive to detecting a request for the first kernel, retrieving the first kernel from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second kernel, retrieving the second kernel from the second binary file for execution by the second target processor.

### Claim 15 (depends on 14)

The system of claim 14, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the first target processor and the second target processor.

### Claim 16 (depends on 14)

The system of claim 14, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model is independent of the source code from which the intermediate representation of code was pre-compiled.

### Claim 17 (depends on 14)

The system of claim 14, wherein the instructions for the CPU, when executed further cause the production of graphics by:
responsive to detecting a request for the first shader, retrieving the first shader from the first binary file for execution by the first target processor; and
responsive to detecting a request for the second shader, retrieving the second shader from the second binary file for execution by the second target processor.

### Claim 18 (depends on 14)

The system of claim 14, wherein:
a first compiler is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the first binary file; and
a second complier is used to compile the at least a portion of the pre-compiled library from the intermediate representation into the second binary file.

### Claim 19 (depends on 14)

The system of claim 14, wherein the instructions for the CPU, when executed further cause the production of graphics by providing the first kernel to the first target processor for execution and by providing the second kernel to the second target processor for execution.

### Claim 20 (depends on 14)

The system of claim 14, wherein the intermediate representation of code contains instructions conforming to an intermediate representation language model, wherein the intermediate representation language model contains functions for performing parallel graphics operations and functions for performing parallel non-graphics operations.
