fiaccel - Accelerate fixed-point code
Syntax
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
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 enable:blas — Use BLAS library,
if available disable:blas — Do not use
BLAS library
If not specified, fiaccel uses
inlining and BLAS library functions 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 testbench and compute the moving average. Then, use fiaccel to
accelerate the code and compare.
function avg = testbench_moving_average(x)
%#codegen
if nargin < 1,
x = sfi(rand(100,1),16,15);
end
z = sfi(zeros(10,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 = sfi(zeros(10,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 = sfi(rand(100,1),16,15);
fiaccel testbench_moving_average -args {x} -report
% Compare the non-accelerated and accelerated code.
x = sfi(rand(100,1),16,15);
% Non-compiled version
tic,avg = testbench_moving_average(x);toc
% Compiled version
tic,avg = testbench_moving_average_mex(x);toc
See Also
coder.ArrayType | coder.Constant | coder.EnumType | coder.FiType | coder.newtype | coder.PrimitiveType | coder.resize | coder.StructType | coder.Type | coder.typeof
How much time do you spend on testing to ensure implementation meets system-level requirements?
Learn more