# US 10,310,830 B2 · Shader profiler

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

- Number: US 10,310,830 B2
- Document ID: US10310830B2
- Status: Granted
- Kind: B2
- Application number: 15/617,625
- Filed: 2017-06-08
- Published: 2018-12-06
- Granted: 2019-06-04
- Earliest claimed: 2017-06-02
- Assignees: Apple Inc.
- Applicants: Apple Inc.
- Inventors: Syed Irfan Zaidi; Sun Tjen Fam; Puyan Lotfi; Venkat R. Indukuru; Jun Pan; Andrew M. Sowerby; Jean-Luc Duprat
- Web page: https://patentgrep.com/patent/US10310830B2

## CPC

- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F 9/3856: {Reordering of instructions, e.g. using queues or age tags}
- G06T 15/005: {General purpose rendering architectures}
- G06F 8/38: for implementing user interfaces
- G06F 11/3636: {by tracing the execution of the program}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL

## Abstract

Systems, methods, and computer readable media to improve the development of image processing intensive programs are described. In general, techniques are disclosed to non-intrusively monitor the run-time performance of shader programs on a graphics processing unit (GPU)—that is, to profile shader program execution. More particularly, the shader profiling comprises of sampling data during the execution of a compiled code on GPU. The execution duration of the sequences of instructions within the code is determined. Subsequently, based relative latency of the instructions within the sequence, the duration time for each binary instruction is determined. The binary instructions are then mapped to source code in order to obtain the amount of time each source code instruction in a shader take to execute per draw call.

## Claims

### Claim 1

A program development method, comprising:
obtaining a trace for execution of a compiled shader program, the compiled shader program having a plurality of overlapping instruction sequences, each overlapping instruction sequence having one or more binary instructions, the compiled shader program having a corresponding plurality of source code instructions;
executing the trace a plurality of times to obtain trace packet content for the plurality of overlapping instruction sequences;
identifying an overlapping instruction sequence of the compiled shader program that is uninterrupted during said executing and parsing the trace packet content to determine a time duration for each binary instruction of the identified instruction sequence;
determining an execution duration for the identified instruction sequence based on the parsed trace packet content;
identifying one or more of the source code instructions corresponding to each binary instruction of the identified instruction sequence;
determining a time duration for each of the identified source code instructions of the identified instruction sequence based on the time duration for the identified source code instructions' corresponding binary instruction; and
displaying the identified source code instructions and each source code instruction's corresponding time duration.

### Claim 2 (depends on 1)

The method of claim 1, wherein determining a time duration for each binary instruction of the identified instruction sequence comprises:
identifying relative latencies among the binary instructions within the identified instruction sequence; and
distributing the execution duration among the binary instructions within the identified instruction sequence based on the determined relative latencies.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
determining a number of the overlapping instruction sequences that are executed simultaneously; and
distributing an execution cost equally among the determined instruction sequences that are executed simultaneously.

### Claim 4 (depends on 1)

The method of claim 1, wherein the trace packet content comprises at least one of:
an offset value of a first sequence of instructions within the compiled shader program;
a scheduled time for execution of the plurality of instruction sequences; and
an end time of the execution of the plurality of instruction sequences.

### Claim 5 (depends on 4)

The method of claim 4, further comprises:
normalizing the execution duration of the plurality of overlapping instruction sequences based on the scheduled time associated with at least one of the plurality of overlapping instruction sequences.

### Claim 6 (depends on 1)

The method of claim 1, further comprises:
determining an address range for each of the plurality of overlapping instruction sequences, the address range indicative of a region of memory in which respective binary instructions were stored during the execution of the trace.

### Claim 7 (depends on 6)

The method of claim 6, wherein determining [a] the time duration for each binary instruction of the identified instruction sequence is based on the address range, a scheduled time, and an end time corresponding to the identified instruction sequence.

### Claim 8

A non-transitory program storage device comprising instructions stored thereon to cause one or more processors to:
obtain a trace for execution of compiled shader program, the compiled shader program having a plurality of overlapping instruction sequences, each overlapping instruction sequence having one or more binary instructions, the compiled shader program having a corresponding plurality of source code instructions;
execute the trace a plurality of times to obtain trace packet content for the plurality of overlapping instruction sequences;
identify an overlapping instruction sequence of the compiled shader program that is uninterrupted when executing the trace and parse the trace packet content to determine a time duration for each binary instruction of the identified instruction sequence;
determine an execution duration for the identified instruction sequence based on the parsed trace packet content;
identify one or more of the source code instructions corresponding to each binary instruction of the identified instruction sequence;
determine a time duration for each of the identified source code instructions of the identified instruction sequence based on the time duration for the identified source code instructions' corresponding binary instruction; and
display the identified source code instructions and each source code instruction's corresponding time duration.

### Claim 9 (depends on 8)

The non-transitory program storage device of claim 8, wherein the instructions to determine a time duration for each binary instruction of the identified instruction sequence comprise instructions to cause the one or more processors to:
identify relative latencies among the binary instructions within the identified instruction sequence; and
distribute the execution duration among the binary instructions within the identified instruction sequence based on the determined relative latencies.

### Claim 10 (depends on 8)

The non-transitory program storage device of claim 8, wherein the instructions further cause the one or more processors to:
determine a number of the overlapping instruction sequences that are executed simultaneously; and
distribute an execution cost equally among the determined instruction sequences that are executed simultaneously.

### Claim 11 (depends on 8)

The non-transitory program storage device of claim 8, wherein the trace packet content comprises at least one of:
an offset value of a first sequence of instructions within the compiled shader program;
a scheduled time for execution of the plurality of instruction sequences; and
an end time of the execution of the plurality of instruction sequences.

### Claim 12 (depends on 11)

The non-transitory program storage device of claim 11, further comprising instructions to:
normalize the execution duration of the plurality of overlapping instruction sequences based on the scheduled time associated with at least one of the plurality of overlapping instruction sequences.

### Claim 13 (depends on 8)

The non-transitory program storage device of claim 8, further comprising instructions to:
determine an address range for each of the plurality of overlapping instruction sequences, the address range indicative of a region of memory in which the respective binary instructions were stored during the execution of the trace.

### Claim 14 (depends on 13)

The non-transitory program storage device of claim 13, wherein the instructions to determine the time duration for each binary instruction of the identified instruction sequence is based on the address range, a scheduled time, and an end time corresponding to the identified instruction sequence.

### Claim 15

A system comprising:
a central processing unit (CPU),
a graphics processing unit (GPU), and
a memory coupled to the device CPU and the GPU, wherein the memory comprises instructions to—
obtain a trace for execution of a compiled shader program having a plurality of overlapping instruction sequences, each overlapping instruction sequence having one or more binary instructions, the compiled shader program having a corresponding plurality of source code instructions;
execute the trace a plurality of times to obtain trace packet content for the plurality of overlapping instruction sequences;
identify an overlapping instruction sequence of the compiled shader program that is uninterrupted during when executing the trace and parse the trace packet content to determine a time duration for each binary instruction of the identified instruction sequence;
determine an execution duration for the identified instruction sequence based on the parsed trace packet content;
identify one or more of the source code instructions corresponding to each binary instruction of the identified instruction sequence;
determine a time duration for each of the identified source code instructions of the identified instruction sequence based on the time duration for the identified source code instructions' corresponding binary instruction; and
display the identified source code instructions and each source code instruction's corresponding time duration.

### Claim 16 (depends on 15)

The system of claim 15, wherein the instructions to determine a time duration for each binary instruction of the identified instruction sequence comprise instructions to cause the one or more processors to:
identify relative latencies among the binary instructions within the identified instruction sequence; and
distribute the execution duration among the binary instructions within the identified instruction sequence based on the determined relative latencies.

### Claim 17 (depends on 15)

The system of claim 15, wherein the instructions further cause the one or more processors to:
determine a number of the overlapping instruction sequences that are executed simultaneously; and
distribute an execution cost equally among the determined instruction sequences that are executed simultaneously.

### Claim 18 (depends on 15)

The system of claim 15, wherein the trace packet content comprises at least one of:
an offset value of a first sequence of instructions within the compiled shader program;
a scheduled time for execution of the plurality of instruction sequences; and
an end time of the execution of the plurality of instruction sequences.

### Claim 19 (depends on 15)

The system of claim 15, further comprising instructions to:
normalize the execution duration of the plurality of overlapping instruction sequences based on the scheduled time associated with the at least one of the plurality of overlapping instruction sequences.

### Claim 20 (depends on 15)

The system of claim 15, further comprising instructions to:
determine an address range for each of the plurality of overlapping instruction sequences, the address range indicative of a region of memory in which respective binary instructions were stored during the execution of the trace.
