# US 2021/0342155 A1 · System and method for prefetching instructions and data

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

- Number: US 2021/0342155 A1
- Document ID: US20210342155A1
- Status: Published application
- Kind: A1
- Application number: 16/866,202
- Filed: 2020-05-04
- Published: 2021-11-04
- Earliest claimed: 2020-05-04
- Assignees: Morgan Stanley Services Group Inc.
- Applicants: Morgan Stanley Services Group Inc.
- Inventors: Jordan Homer
- Web page: https://patentgrep.com/patent/US20210342155A1

## CPC

- G06F 9/3804: {for branches, e.g. hedging, branch folding}
- G06F 9/3842: {Speculative instruction execution}
- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- G06F 9/30098: {Register arrangements}
- G06F 9/3802: {Instruction prefetching}
- G06F 9/383: {Operand prefetching (cache prefetching G06F12/0862)}
- G06F 9/3856: {Reordering of instructions, e.g. using queues or age tags}
- G06F 9/3861: {Recovery, e.g. branch miss-prediction, exception handling (error detection or correction G06F11/00)}
- G06F 9/4403: {Processor initialisation}
- G06F 9/445: Program loading or initiating (bootstrapping G06F9/4401; security arrangements for program loading or initiating G06F21/57)
- G06F 11/3636: {by tracing the execution of the program}
- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 12/0862: with prefetch
- G06F 2212/6024: History based prefetching
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods for prefetching instructions and data run a program in a test environment, execute a tracing application on the program to collect processor trace data, use the processor trace data to extract a plurality of instruction addresses and a single continuous stack range to be prefetched during a run-time of the program, at initialization of the program, load the extracted plurality of instruction addresses and the extracted stack range, relocate the plurality of extracted instruction addresses and the extracted stack range into the program, and at run-time, prefetch one or more of the plurality of extracted instruction addresses and the extracted stack range during idle time of the program.

## Claims

### Claim 1

A method for prefetching instructions and data, comprising:
running, by the processor, a program in a test environment;
executing, by the processor, a tracing application on the program to collect processor trace data;
using, by the processor, the processor trace data to extract a plurality of instruction addresses and a single continuous stack range to be prefetched during a run-time of the program;
at initialization of the program, loading by the processor the extracted plurality of instruction addresses and the extracted stack range;
relocating, by the processor, the plurality of extracted instruction addresses and the extracted stack range into the program; and
at run-time, prefetching by the processor one or more of the plurality of extracted instruction addresses and the extracted stack range during idle time of the program.

### Claim 2 (depends on 1)

The method as in claim 1, wherein the stack range is determined from a sequence of stack-operating instructions in the instruction trace.

### Claim 3 (depends on 1)

The method as in claim 1, wherein prefetching the one or more of the plurality of extracted instruction addresses and the extracted stack range further comprises:
executing, by the processor, an instruction to begin transactional execution and specify a fallback address;
wherein the fallback address provides a safe exit from the transactional execution in the event of an aborted execution;
issuing, by the processor, an instruction with a fault which, upon retirement, causes transactional execution to abort;
jumping, by the processor, into an instruction address to be prefetched prior to the retirement of the exception-causing instruction;
retiring the exception-causing instruction; and
re-steering, by the processor, execution to the fallback address.

### Claim 4 (depends on 2)

The method as in claim 2, wherein one or more architectural registers of the processor are rendered unavailable while executing the faulting instruction at and beyond a prefetch address; and
wherein, each of the one or more architectural registers is given a data dependency on the faulting instruction.

### Claim 5 (depends on 2)

The method as in claim 2, further comprising delaying the execution of the fault by calculating a load address as a result of a data dependent chain of register-to-register instructions.

### Claim 6 (depends on 5)

The method as in claim 5, wherein the length of the delay is adjusted by controlling the number of instructions.

### Claim 7 (depends on 1)

The method as in claim 1, further comprising, prefetching two or more lines in reverse order.

### Claim 8 (depends on 1)

The method as in claim 1, further comprising, prefetching all addresses at once, wherein the prefetching is repeated only after a predefined duration.

### Claim 9 (depends on 1)

The method as in claim 1, further comprising prefetching a beginning of every basic block that follows a branch.

### Claim 10 (depends on 1)

The method as in claim 1, further comprising prefetching any time an interval between branches exceeds at least one of a predefined number of bytes and a predefined number of instructions.

### Claim 11

A system for prefetching instructions and data, comprising:
a server having a processor, and memory; and
one or more code sets stored in the memory and executing in the processor, which, when executed, configure the processor to:
run a program in a test environment;
execute a tracing application on the program to collect processor trace data;
use the processor trace data to extract a plurality of instruction addresses and a single continuous stack range to be prefetched during a run-time of the program;
at initialization of the program, load the extracted plurality of instruction addresses and the extracted stack range;
relocate the plurality of extracted instruction addresses and the extracted stack range into the program; and
at run-time, prefetch one or more of the plurality of extracted instruction addresses and the extracted stack range during idle time of the program.

### Claim 12 (depends on 11)

The system as in claim 11, wherein the stack range is determined from a sequence of stack-operating instructions in the instruction trace.

### Claim 13 (depends on 11)

The system as in claim 11, wherein, when prefetching the one or more of the plurality of extracted instruction addresses and the extracted stack range, the processor is further configured to:
execute an instruction to begin transactional execution and specify a fallback address;
wherein the fallback address provides a safe exit from the transactional execution in the event of an aborted execution;
issue an instruction with a fault which, upon retirement, causes transactional execution to abort;
jump into an instruction address to be prefetched prior to the retirement of the exception-causing instruction;
retire the exception-causing instruction; and
re-steer execution to the fallback address.

### Claim 14 (depends on 12)

The system as in claim 12, wherein one or more architectural registers of the processor are rendered unavailable while executing the faulting instruction at and beyond a prefetch address; and
wherein, each of the one or more architectural registers is given a data dependency on the faulting instruction.

### Claim 15 (depends on 12)

The system as in claim 12, wherein the processor is further configured to delay the execution of the fault by calculating a load address as a result of a data dependent chain of register-to-register instructions.

### Claim 16 (depends on 15)

The system as in claim 15, wherein the length of the delay is adjusted by controlling the number of instructions.

### Claim 17 (depends on 11)

The system as in claim 11, wherein the processor is further configured to prefetch two or more lines in reverse order.

### Claim 18 (depends on 11)

The system as in claim 11, wherein the processor is further configured to prefetch all addresses at once, wherein the prefetching is repeated only after a predefined duration.

### Claim 19 (depends on 11)

The system as in claim 11, wherein the processor is further configured to prefetch a beginning of every basic block that follows a branch.

### Claim 20 (depends on 11)

The system as in claim 11, wherein the processor is further configured to prefetch any time an interval between branches exceeds at least one of a predefined number of bytes and a predefined number of instructions.
