# US 8,578,347 B1 · Determining stack usage of generated code from a model

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

- Number: US 8,578,347 B1
- Document ID: US8578347B1
- Status: Granted
- Kind: B1
- Application number: 11/646,848
- Filed: 2006-12-28
- Granted: 2013-11-05
- Earliest claimed: 2006-12-28
- Assignees: The MathWorks, Inc.
- Applicants: James Carrick; Peter Szpak
- Inventors: James Carrick; Peter Szpak
- Web page: https://patentgrep.com/patent/US8578347B1

## CPC

- G06F 11/3447: {Performance evaluation by modeling}
- G06F 8/75: Structural analysis for program understanding
- G06F 11/3409: {for performance assessment}
- G06F 11/362: Debugging of software
- G06F 8/35: model driven
- G06F 2201/865: Monitoring of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In one embodiment, a method of determining stack usage of at least a portion of a model for deployment on a target system is provided. The method may include obtaining information describing a first target system, and using the information to estimate a stack usage related to executing a representation of a component of the model on the first target system.

## Claims

### Claim 1

A method implemented in an electronic device, the method comprising:
obtaining information describing a first target system;
using the information to estimate s maximum stack usage, the maximum stack usage:
representing a usage of a stack of the first target system at a given time, related to executing a model on the first target system, determined without executing the model,
and
estimated by;
representing function calls of the model as a function call tree, the function call tree having a plurality of invocation paths representing call chains in the model, and
identifying a most expensive one of the plurality of invocation paths in the function call tree, wherein the most expensive one of the plurality of invocation paths is associated with a most-expensive-path stack usage for others of the plurality of paths; and
setting the maximum stack usage to the most-expensive stack usage.

### Claim 2 (depends on 1)

The method of claim 1, wherein the model is implemented in a text-based programming environment or text-based modeling environment.

### Claim 3 (depends on 1)

The method of claim 1, wherein the model is a graphical model.

### Claim 4 (depends on 1)

The method of claim 1, wherein the using the information to estimate the maximum stack usage is performed during compilation of the model.

### Claim 5 (depends on 3)

The method of claim 3, wherein the graphical model is implemented in a SIMULINK-compatible environment.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
generating an intermediate representation of the model; and
using the intermediate representation to estimate the maximum stack usage.

### Claim 7 (depends on 1)

The method of claim 1, wherein the information describing the first target system includes information about an amount of memory used for a data type on the first target system.

### Claim 8 (depends on 1)

The method of claim 1, wherein the information describing the first target system includes information about stack usage on the first target system.

### Claim 9 (depends on 1)

The method of claim 1, further comprising:
displaying the estimated maximum stack usage.

### Claim 10 (depends on 9)

The method of claim 9, further comprising:
displaying, in the model, a second estimated maximum stack usage associated with the model using information related to a second target system.

### Claim 11 (depends on 1)

The method of claim 1, further comprising:
specifying a stack usage limit for the model;
determining whether the maximum stack usage exceeds the stack usage limit; and
making a graphical annotation on the model when the maximum stack usage exceeds the stack usage limit, the graphical annotation indicating that the stack usage limit is exceeded.

### Claim 12 (depends on 11)

The method of claim 11, further comprising:
providing a user interface for a user to indicate the stack usage limit.

### Claim 13 (depends on 11)

The method of claim 11, further comprising:
receiving an input to modify the stack usage limit or the model.

### Claim 14 (depends on 13)

The method of claim 13, wherein the input is configured to prevent the stack usage limit from being exceeded.

### Claim 15 (depends on 1)

The method of claim 1, wherein the information describing the first target system is obtained from the first target system or a user.

### Claim 16 (depends on 1)

The method of claim 1, further comprising:
providing a user interface displaying information about a stack usage limit for the first target system, a desired stack usage for the first target system, and an estimated stack usage on the first target system for the model when the model is converted into code for use on the first target system.

### Claim 17 (depends on 1)

The method of claim 1, further comprising:
generating a report including an execution stack usage related to executing the model on the first target system.

### Claim 18

A system comprising:
a memory for storing a plurality of components of a model, the model operating in a modeling or programming environment, the modeling or programming environment obtaining information describing a first target system; and
a processor configured to:
provide a stack usage calculator to estimate a maximum stack usage for executing a representation of the plurality of components on the first target system, the maximum stack usage:
representing a usage of a stack of the first target system at a given time,
determined without executing the representation of the plurality of components, and
estimated by:
representing function calls of the model as a function call tree, the function call tree having a plurality of invocation paths representing function call chains in the model, and
identifying a most expensive one of the plurality of invocation paths in the function call tree, wherein the most expensive one of the plurality of invocation paths is associated with a most-expensive-path stack usage, the most expensive stack usage exceeding a stack usage for others of the plurality of paths; and
set the maximums stack usage to most-expensive-path usage.

### Claim 19 (depends on 18)

The system of claim 18, further comprising:
a compiler, the compiler configured to:
compile the model, and
generate an intermediate representation of the model, the intermediate representation being used to provide the estimate of the maximum stack usage.

### Claim 20 (depends on 18)

The system of claim 18, wherein the maximum stack usage of the representation of the plurality of components is displayed in the model.

### Claim 21 (depends on 18)

The system of claim 18, wherein the information describing the first target system includes information about stack usage on the first target system.

### Claim 22 (depends on 18)

The system of claim 18, further comprising:
a code generator to automatically generate code based on the model.

### Claim 23 (depends on 18)

The system of claim 18, further comprising:
a report generator generating a report including the estimate of the maximum stack usage.

### Claim 24 (depends on 18)

The system of claim 18, further comprising:
a user interface displaying information about a stack usage limit for the first target system, a desired stack usage for the first target system, and an estimated stack usage on the first target system for the component when the component is converted into code for use on the first target system.

### Claim 25 (depends on 24)

The system of claim 24, wherein the user interface allows a user to specify the stack usage limit or the desired stack usage.

### Claim 26

A non-transitory medium storing executable instructions executable by a computing device:
obtain information describing a first target system;
use the information to estimate a maximum stack usage, the maximum stack usage:
representing a usage of a stack of the first target system at a given time,
related to executing a model on the first target system,
determined without executing the model, and
estimated by:
representing function calls of the model as a function call tree, the function call tree having a plurality of invocation paths representing function call chains in the model, and
identifying a most expensive one of the plurality of invocation paths in the function call tree, wherein the most expensive one of the plurality of invocation paths is associated with a most-expensive-path stack usage that exceeds a stack usage for others of the plurality of paths;
setting the maximum stack usage to the most-expensive-path stack usage; and
storing the maximum stack usage in a storage.

### Claim 27 (depends on 26)

The medium of claim 26, further storing:
instructions for generating an intermediate representation of the model; and
instructions for using the intermediate representation to estimate the maximum stack usage.

### Claim 28 (depends on 26)

The medium of claim 26, wherein the information describing the first target system includes information about stack usage on the first target system.

### Claim 29 (depends on 26)

The medium of claim 26, wherein the using the information to estimate the maximum stack usage is performed during compilation of the model.

### Claim 30 (depends on 26)

The medium of claim 26, further storing:
instructions for displaying the estimate of the maximum stack usage.

### Claim 31 (depends on 30)

The medium of claim 30, further comprising:
instructions for displaying, in the model, a second estimated maximum stack usage associated with the model, the second estimated maximum stack usage determined using information related to a second target system.

### Claim 32 (depends on 26)

The medium of claim 26, further comprising:
instructions for specifying a stack usage limit for the model;
instructions for determining whether the maximum stack usage exceeds the stack usage limit; and
instructions for making a graphical annotation on the model when the maximum stack usage exceeds the stack usage limit, the graphical annotation indicating that the stack usage is exceeded.
