# US 2021/0173623 A1 · Systems and methods for stencil amplification

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

- Number: US 2021/0173623 A1
- Document ID: US20210173623A1
- Status: Published application
- Kind: A1
- Application number: 16/927,016
- Filed: 2020-07-13
- Published: 2021-06-10
- Earliest claimed: 2014-10-29
- Assignees: Reservoir Labs, Inc.
- Applicants: Reservoir Labs, Inc.
- Inventors: Thomas Henretty; Richard A. Lethin; Benoit J. Meister
- Web page: https://patentgrep.com/patent/US20210173623A1

## CPC

- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F 8/4434: {Reducing the memory space required by the program code}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In a sequence of major computational steps or in an iterative computation, a stencil amplifier can increase the number of data elements accessed from one or more data structures in a single major step or iteration, thereby decreasing the total number of computations and/or communication operations in the overall sequence or the iterative computation. Stencil amplification, which can be optimized according to a specified parameter such as compile time, rune time, code size, etc., can improve the performance of a computing system executing the sequence or the iterative computation in terms of run time, memory load, energy consumption, etc. The stencil amplifier typically determines boundaries, to avoid erroneously accessing data elements not present in the one or more data structures.

## Claims

### Claim 1

A method for improving processing efficiency, the method comprising performing by a processor the steps of:
in a computation sequence comprising a plurality of sequence steps, identifying a computation using a stencil comprising a set of stencil points, each stencil point corresponding to a value of a respective element of a data structure in a current sequence step; and
modifying the computation by replacing a stencil point with a first-level substencil comprising a set of first-level substencil points, each first-level substencil point corresponding to a value of a respective element of the data structure from a first previous sequence step, at least one first-level substencil point being associated with a data-structure element that is different from data-structure elements associated with all stencil points.

### Claim 2 (depends on 1)

The method of claim 1, wherein modifying the computation comprises generating a loop nest corresponding to at least one stencil point, the loop nest comprising a loop corresponding to a parameterized dimension of the data structure, the loop comprising a statement accessing an element of the data structure in the parameterized dimension according to a parameter based at least in part on the loop index.

### Claim 3 (depends on 2)

The method of claim 2, wherein the loop nest corresponds to at least one absolute dimension of the data structure.

### Claim 4 (depends on 1)

The method of claim 1, wherein modifying the computation comprises generating a statement corresponding to a stencil point at which all dimensions of the data structure are absolute.

### Claim 5 (depends on 1)

The method of claim 1, wherein one of identifying and modifying the computation comprises:
representing the computation as a function of values of respective elements of the data structure corresponding to the set of stencil points, each element of the data structure being specified using a central vector associated with the stencil and an offset vector associated with a corresponding stencil point, a cardinality of the central vector and a cardinality of the offset vector being equal to a number of spatial dimensions of the data structure, and each spatial dimension of the data structure corresponding to a respective element of the central vector and a respective element of the offset vector.

### Claim 6 (depends on 5)

The method of claim 5, wherein modifying the computation comprises:
for each first-level substencil point of the first-level substencil, computing a first-level resulting offset vector as a combination of the offset vector associated with the stencil point and an offset vector corresponding to that first-level substencil point; and
representing the stencil point as a function of values of respective elements of the data structure corresponding to the set of first-level substencil points, each element of the data structure being specified using a central vector associated with the stencil and a first-level resulting offset vector associated with a corresponding first-level substencil point.

### Claim 7 (depends on 6)

The method of claim 6, further comprising:
for each spatial dimension associated with the resulting offset vectors corresponding to the first-level substencil:
determining a first-level maximum offset value; and
from a boundary of the data structure in that spatial dimension, designating any data-structure element within a distance less than the first-level maximum offset value as a boundary element;
designating a stencil point from the set of stencil points as a boundary point if that stencil point corresponds to a boundary element; and
selecting a stencil point from the stencil, for replacement thereof with the first-level substencil, only if that stencil point is not designated as a boundary point.

### Claim 8 (depends on 6)

The method of claim 6, further comprising:
remodifying the computation by replacing a first-level substencil point with a second-level substencil comprising a set of second-level substencil points, each second-level substencil point corresponding to a value of a respective element of the data structure from a second previous sequence step, at least one second-level substencil point being associated with a data-structure element that is different from data-structure elements associated with all stencil points and all first-level substencil points.

### Claim 9 (depends on 8)

The method of claim 8, wherein modifying the computation further comprises:
for each second-level substencil point of the second-level substencil, computing a second-level resulting offset vector as a combination of the first-level resulting offset vector associated with a first-level substencil point to be replaced with the second-level substencil and an offset vector corresponding to that second-level substencil point; and
representing the first-level substencil point as a function of values of respective elements of the data structure corresponding to the set of second-level substencil points, each element of the data structure being specified using a central vector associated with the stencil and a second-level resulting offset vector associated with a corresponding second-level substencil point.

### Claim 10 (depends on 9)

The method of claim 9, further comprising:
for each spatial dimension associated with the resulting offset vectors corresponding to the second-level substencil:
determining a second-level maximum offset value; and
from a boundary of the data structure in that spatial dimension, designating any data-structure element within a distance less than the second-level maximum offset value as a boundary element;
designating a stencil point from the set of stencil points as a boundary point if that stencil point corresponds to a boundary element; and
selecting a stencil point from the stencil, for replacement thereof with the second-level substencil, only if that stencil point is not designated as a boundary point.

### Claim 11 (depends on 8)

The method of claim 8, wherein at least one of: (i) a cardinality of the set of first-level substencil points, and (ii) a cardinality of the set of second-level substencil points is greater than one.

### Claim 12 (depends on 1)

The method of claim 1, wherein:
each stencil point in a subset of stencil points from the set of stencil points is associated with a respective stencil coefficient;
each first-level substencil point in a subset of first-level substencil points from the set of first-level stencil points is associated with a respective first-level substencil coefficient; and
modifying the computation comprises generating a coefficient computation that produces a resulting coefficient, based on a stencil coefficient and a first-level substencil coefficient.

### Claim 13 (depends on 12)

The method of claim 12, wherein:
the computation comprises a first stencil point and a second stencil point;
modifying the computation comprises:
replacing the first stencil point, having associated therewith a first stencil coefficient, with a first first-level substencil comprising a first first-level substencil point, having associated therewith a first substencil coefficient, and corresponding to a particular element of the data structure; and
replacing the second stencil point, having associated therewith a second stencil coefficient, with a second first-level substencil comprising a second first-level substencil point, having associated therewith a second substencil coefficient, and corresponding to the particular element of the data structure; and
generating the coefficient computation comprises specifying a transform operation that produces the resulting coefficient, the transform operation comprising the first and second stencil coefficients and the first and second substencil coefficients.

### Claim 14 (depends on 12)

The method of claim 12, further comprising computing at compile time a value of the resulting coefficient.

### Claim 15 (depends on 12)

The method of claim 12, wherein the computation sequence is specified using a sequential iterator and each sequence step corresponds to a respective iteration of the sequential iterator, the method further comprising hoisting the coefficient computation from the sequential iterations, thereby decreasing a number of computations within an iteration corresponding to the sequential iterator.

### Claim 16 (depends on 1)

The method of claim 1, wherein the computation sequence is specified using a sequential iterator and each sequence step corresponds to a respective iteration of the sequential iterator, the method further comprising decreasing a number of iterations of the sequential iterator according to an amplification factor.

### Claim 17 (depends on 1)

The method of claim 1, wherein:
each stencil point in a subset of stencil points from the set of stencil points is associated with a respective stencil coefficient; and
the respective stencil coefficient comprises a value corresponding to an element of the data structure corresponding to a respective first-level substencil point from the set of first-level substencil points.

### Claim 18 (depends on 1)

The method of claim 1, wherein the data structure comprises a plurality of arrays.

### Claim 19 (depends on 18)

The method of claim 18, wherein:
the plurality of arrays comprises a first array comprising at least one sequence-step-dependent value and a second array;
each stencil point in the set of stencil points corresponds to a value of a respective element of the first array in a current sequence step and a value of a respective element of the second array; and
each first-level substencil point in the set of first-level substencil points corresponds to a value of a respective element of the first array from a previous sequence step.

### Claim 20 (depends on 19)

The method of claim 19, wherein:
the second array comprises at least one sequence-step-dependent value; and
each first-level substencil point in the set of first-level substencil points further corresponds to a value of a respective element of the second array from a previous sequence step.

### Claim 21

A system for amplifying a stencil, the system comprising:
a first processor; and
a first memory in electrical communication with the first processor, the first memory comprising instructions which, when executed by a processing unit comprising at least one of the first processor and a second processor, and in electronic communication with a memory module comprising at least one of the first memory and a second memory, program the processing unit to:
identify, in a computation sequence comprising a plurality of sequence steps, a computation using a stencil comprising a set of stencil points, each stencil point corresponding to a value of a respective element of a data structure in a current sequence step; and
modify the computation by replacing a stencil point with a first-level substencil comprising a set of first-level substencil points, each first-level substencil point corresponding to a value of a respective element of the data structure from a first previous sequence step, at least one first-level substencil point being associated with a data-structure element that is different from data-structure elements associated with all stencil points.

### Claim 22 (depends on 21)

The system of claim 21, wherein to modify the computation, the instruction program the processing unit to generate a loop nest corresponding to at least one stencil point, the loop nest comprising a loop corresponding to a parameterized dimension of the data structure, the loop comprising a statement accessing an element of the data structure in the parameterized dimension according to a parameter based at least in part on the loop index.

### Claim 23 (depends on 22)

The system of claim 22, wherein the loop nest corresponds to at least one absolute dimension of the data structure.

### Claim 24 (depends on 21)

The system of claim 21, wherein to modify the computation, the instructions further program the processing unit to generate a statement corresponding to a stencil point at which all dimensions of the data structure are absolute.

### Claim 25 (depends on 21)

The system of claim 21, wherein one of to identify and to modify the computation, the instructions further program the processing unit to:
represent the computation as a function of values of respective elements of the data structure corresponding to the set of stencil points; and
to specify each element of the data structure using a central vector associated with the stencil and an offset vector associated with a corresponding stencil point, a cardinality of the central vector and a cardinality of the offset vector being equal to a number of spatial dimensions of the data structure, and each spatial dimension of the data structure corresponding to a respective element of the central vector and a respective element of the offset vector.

### Claim 26 (depends on 25)

The system of claim 25, wherein to modify the computation, the instructions further program the processing unit to:
compute, for each first-level substencil point of the first-level substencil, a first-level resulting offset vector as a combination of the offset vector associated with the stencil point and an offset vector corresponding to that first-level substencil point;
represent the stencil point as a function of values of respective elements of the data structure corresponding to the set of first-level substencil points; and
specify each element of the data structure using a central vector associated with the stencil and a first-level resulting offset vector associated with a corresponding first-level substencil point.

### Claim 27 (depends on 26)

The system of claim 26, wherein the instructions further program the processing unit to:
for each spatial dimension associated with the resulting offset vectors corresponding to the first-level substencil:
determine a first-level maximum offset value; and
from a boundary of the data structure in that spatial dimension, designate any data-structure element within a distance less than the first-level maximum offset value as a boundary element;
designate a stencil point from the set of stencil points as a boundary point if that stencil point corresponds to a boundary element; and
select a stencil point from the stencil, for replacement thereof with the first-level substencil, only if that stencil point is not designated as a boundary point.

### Claim 28 (depends on 26)

The system of claim 26, wherein the instructions further program the processing unit to:
remodify the computation by replacing a first-level substencil point with a second-level substencil comprising a set of second-level substencil points, each second-level substencil point corresponding to a value of a respective element of the data structure from a second previous sequence step, at least one second-level substencil point being associated with a data-structure element that is different from data-structure elements associated with all stencil points and all first-level substencil points.

### Claim 29 (depends on 28)

The system of claim 28, wherein to modify the computation, the instructions further program the processing unit to:
compute, for each second-level substencil point of the second-level substencil, a second-level resulting offset vector as a combination of the first-level resulting offset vector associated with a first-level substencil point to be replaced with the second-level substencil and an offset vector corresponding to that second-level substencil point; and
represent the first-level substencil point as a function of values of respective elements of the data structure corresponding to the set of second-level substencil points, each element of the data structure being specified using a central vector associated with the stencil and a second-level resulting offset vector associated with a corresponding second-level substencil point.

### Claim 30 (depends on 29)

The system of claim 29, wherein the instructions further program the processing unit to:
for each spatial dimension associated with the resulting offset vectors corresponding to the second-level substencil:
determine a second-level maximum offset value; and
from a boundary of the data structure in that spatial dimension, designate any data-structure element within a distance less than the second-level maximum offset value as a boundary element;
designate a stencil point from the set of stencil points as a boundary point if that stencil point corresponds to a boundary element; and
select a stencil point from the stencil, for replacement thereof with the second-level substencil, only if that stencil point is not designated as a boundary point.

### Claim 31 (depends on 28)

The system of claim 28, wherein at least one of: (i) a cardinality of the set of first-level substencil points, and (ii) a cardinality of the set of second-level substencil points is greater than one.

### Claim 32 (depends on 21)

The system of claim 21, wherein:
each stencil point in a subset of stencil points from the set of stencil points is associated with a respective stencil coefficient;
each first-level substencil point in a subset of first-level substencil points from the set of first-level stencil points is associated with a respective first-level substencil coefficient; and
to modify the computation, the instructions further program the processing unit to generate a coefficient computation that produces a resulting coefficient, based on a stencil coefficient and a first-level substencil coefficient.

### Claim 33 (depends on 32)

The system of claim 32, wherein:
the computation comprises a first stencil point and a second stencil point;
to modify the computation, the instructions further program the processing unit to:
replace the first stencil point, having associated therewith a first stencil coefficient, with a first first-level substencil comprising a first first-level substencil point, having associated therewith a first substencil coefficient, and corresponding to a particular element of the data structure; and
replace the second stencil point, having associated therewith a second stencil coefficient, with a second first-level substencil comprising a second first-level substencil point, having associated therewith a second substencil coefficient, and corresponding to the particular element of the data structure; and
to generate the coefficient computation, the instructions further program the processing unit to specify a transform operation that produces the resulting coefficient, the transform operation comprising the first and second stencil coefficients and the first and second substencil coefficients.

### Claim 34 (depends on 32)

The system of claim 32, wherein the instructions further program the processing unit to compute at compile time a value of the resulting coefficient.

### Claim 35 (depends on 32)

The system of claim 32, wherein:
the computation sequence is specified using a sequential iterator and each sequence step corresponds to a respective iteration of the sequential iterator; and
the instructions further program the processing unit to hoist the coefficient computation from the sequential iterations, thereby decreasing a number of computations within an iteration corresponding to the sequential iterator.

### Claim 36 (depends on 21)

The system of claim 21, wherein:
the computation sequence is specified using a sequential iterator and each sequence step corresponds to a respective iteration of the sequential iterator; and
the instructions further program the processing unit to decrease a number of iterations of the sequential iterator according to an amplification factor.

### Claim 37 (depends on 21)

The system of claim 21, wherein:
each stencil point in a subset of stencil points from the set of stencil points is associated with a respective stencil coefficient; and
the respective stencil coefficient comprises a value corresponding to an element of the data structure corresponding to a respective first-level substencil point from the set of first-level substencil points.

### Claim 38 (depends on 21)

The system of claim 21, wherein the data structure comprises a plurality of arrays.

### Claim 39 (depends on 38)

The system of claim 38, wherein:
the plurality of arrays comprises a first array comprising at least one sequence-step-dependent value and a second array;
each stencil point in the set of stencil points corresponds to a value of a respective element of the first array in a current sequence step and a value of a respective element of the second array; and
each first-level substencil point in the set of first-level substencil points corresponds to a value of a respective element of the first array from a previous sequence step.

### Claim 40 (depends on 39)

The system of claim 39, wherein:
the second array comprises at least one sequence-step-dependent value; and
each first-level substencil point in the set of first-level substencil points further corresponds to a value of a respective element of the second array from a previous sequence step.
