Documentation Center

  • Trial Software
  • Product Updates

fiaccel

Accelerate fixed-point code

Syntax

fiaccel -options fcn

Description

fiaccel -options fcn translates the MATLAB® file fcn.m to a MEX function, which accelerates fixed-point code. To use fiaccel, your code must meet one of these requirements:

  • The top-level function has no inputs or outputs, and the code uses fi

  • The top-level function has an output or a non-constant input, and at least one output or input is a fi.

  • The top-level function has at least one input or output containing a built-in integer class (int8, uint8, int16, uint16, int32, uint32, int64, or uint64), and the code uses fi.

    Note:   If your top-level file is on a path that contains Unicode characters, code generation might not be able to find the file.

Input Arguments

fcn

MATLAB function from which to generate a MEX function. fcn must be suitable for code generation. For information on code generation, see Code Acceleration and Code Generation from MATLAB

options

Choice of compiler options. fiaccel gives precedence to individual command-line options over options specified using a configuration object. If command-line options conflict, the rightmost option prevails.

-args example_inputs

Define the size, class, and complexity of all MATLAB function inputs. Use the values in example_inputs to define these properties. example_inputs must be a cell array that specifies the same number and order of inputs as the MATLAB function.

-config config_object

Specify MEX generation parameters, based on config_object, defined as a MATLAB variable using coder.mexconfig. For example:

cfg = coder.mexconfig;
-d out_folder

Store generated files in the absolute or relative path specified by out_folder. If the folder specified by out_folder does not exist, fiaccel creates it for you.

If you do not specify the folder location, fiaccel generates files in the default folder:

fiaccel/mex/fcn. 

fcn is the name of the MATLAB function specified at the command line.

The function does not support the following characters in folder names: asterisk (*), question-mark (?), dollar ($), and pound (#).

-g

Compiles the MEX function in debug mode, with optimization turned off. If not specified, fiaccel generates the MEX function in optimized mode.

-global global_values

Specify initial values for global variables in MATLAB file. Use the values in cell array global_values to initialize global variables in the function you compile. The cell array should provide the name and initial value of each global variable. You must initialize global variables before compiling with fiaccel. If you do not provide initial values for global variables using the -global option, fiaccel checks for the variable in the MATLAB global workspace. If you do not supply an initial value, fiaccel generates an error.

The generated MEX code and MATLAB each have their own copies of global data. To ensure consistency, you must synchronize their global data whenever the two interact. If you do not synchronize the data, their global variables might differ.

-I include_path

Add include_path to the beginning of the code generation path.

fiaccel searches the code generation path first when converting MATLAB code to MEX code.

-launchreport

Generate and open a code generation report. If you do not specify this option, fiaccel generates a report only if error or warning messages occur or you specify the -report option.

-o output_file_name

Generate the MEX function with the base name output_file_name plus a platform-specific extension.

output_file_name can be a file name or include an existing path.

If you do not specify an output file name, the base name is fcn_mex, which allows you to run the original MATLAB function and the MEX function and compare the results.

-O optimization_option

Optimize generated MEX code, based on the value of optimization_option:

  • enable:inline — Enable function inlining

  • disable:inline — Disable function inlining

If not specified, fiaccel uses inlining for optimization.

-report

Generate a code generation report. If you do not specify this option, fiaccel generates a report only if error or warning messages occur or you specify the -launchreport option.

-?

Display help for fiaccel command.

Examples

Create a test file and compute the moving average. Then, use fiaccel to accelerate the code and compare.

function avg = test_moving_average(x)
%#codegen
if nargin < 1,
    x = fi(rand(100,1),1,16,15);
end
z = fi(zeros(10,1),1,16,15);
avg = x;
for k = 1:length(x)
    [avg(k),z] = moving_average(x(k),z);
end

function [avg,z] = moving_average(x,z)
%#codegen
if nargin < 2,
    z = fi(zeros(10,1),1,16,15);
end
z(2:end) = z(1:end-1);  	% Update buffer
z(1) = x;	              	% Add new value
avg = mean(z);          % Compute moving average

% Use fiaccel to create a MEX function and 
% accelerate the code
x = fi(rand(100,1),1,16,15);
fiaccel test_moving_average -args {x} -report

% Compare the non-accelerated and accelerated code.
x = fi(rand(100,1),1,16,15);

% Non-compiled version
tic,avg = test_moving_average(x);toc
% Compiled version
tic,avg = test_moving_average_mex(x);toc

See Also

| | | | | | | | |

Was this topic helpful?