gusucode.com > target工具箱matlab源码程序 > target/extensions/processor/intelhost/tfl/intel_sse_tfl_table.m

    function hLib = intel_sse_tfl_table

%   Copyright 2010-2014 The MathWorks, Inc.
 
hLib = RTW.TflTable;

SrcPath = fullfile('$(MATLAB_ROOT)',...
    'toolbox',...
    'target',...
    'extensions',...
    'processor',...
    'intelhost',...
    'tfl');

IncPath = SrcPath;

% f32x4
add_sse_mm_add_entry(hLib, 'mw_gcc_sse_mm_add_f32x4', 'single', 'RTW_OP_ADD', 100, SrcPath, IncPath, [ 1   1; inf, inf], 16, 'RTW_CAST_AFTER_OP');
add_sse_mm_add_entry(hLib, 'mw_gcc_sse_mm_sub_f32x4', 'single', 'RTW_OP_MINUS', 100, SrcPath, IncPath, [ 1   1; inf, inf], 16, 'RTW_CAST_AFTER_OP');
add_sse_mv_mult_entry_f32x4(hLib, 'mw_gcc_sse_mv_mul_f32x4', 'single', 'RTW_OP_MUL', 100, SrcPath, IncPath, [ 1   4; inf, inf], [ 1   1; inf, 1], [ 1   1; inf, 1], 16);
add_sse_mm_mult_entry_f32x4(hLib, 'mw_gcc_sse_mm_mul_f32x4', 'single', 'RTW_OP_MUL', 100, SrcPath, IncPath, [ 1   4; inf, inf], [ 4   1; inf, inf], [ 1   1; inf, inf], 16);

% f64x2
add_sse_mm_add_entry(hLib, 'mw_gcc_sse_mm_add_f64x2', 'double', 'RTW_OP_ADD', 100, SrcPath, IncPath, [ 1   1; inf, inf], 16, 'RTW_CAST_AFTER_OP');
add_sse_mm_add_entry(hLib, 'mw_gcc_sse_mm_sub_f64x2', 'double', 'RTW_OP_MINUS', 100, SrcPath, IncPath, [ 1   1; inf, inf], 16, 'RTW_CAST_AFTER_OP');
add_sse_mv_mult_entry_f64x2(hLib, 'mw_gcc_sse_mv_mul_f64x2', 'double', 'RTW_OP_MUL', 100, SrcPath, IncPath, [ 1   2; inf, inf], [ 1   1; inf, 1], [ 1   1; inf, 1], 16);
add_sse_mm_mult_entry_f64x2(hLib, 'mw_gcc_sse_mm_mul_f64x2', 'double', 'RTW_OP_MUL', 100, SrcPath, IncPath, [ 1   2; inf, inf], [ 2   1; inf, inf], [ 1   1; inf, inf], 16);

end

%%
function add_sse_mm_add_entry(hLib, implname, dtype, key, priority, srcPath, incPath, bounds, align, algo)

e = IntelHostTFL.SSEMatrMatrAddEntry;
e = locSetEntryParam(e, key, priority, implname, srcPath, incPath);
e.EntryInfo.Algorithm = algo;
locEntryMMAdd(hLib, e, dtype, bounds, bounds, bounds, align);

end


% -------------------------------------------------------------------------
function locEntryMMAdd( hLib, hEnt, dtype, in1Dims, in2Dims, outDims, align )

if isempty(hLib) || isempty( hEnt )
    return;
end

if(align > 0)
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    hEnt.Implementation.ArgumentDescriptor = des;
end

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix',...
        'Name',         'y1', ...
        'BaseType',     dtype, ...
        'IOType',       'RTW_IO_OUTPUT', ...
        'DimRange',     outDims);    

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u1', 'BaseType', dtype, 'DimRange', in1Dims);

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u2', 'BaseType', dtype, 'DimRange', in2Dims);

% Specify replacement function Signature
% sse_mmadd(in1, row, col, in2, out)

arg = hLib.getTflArgFromString('y2','void');
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.Implementation.setReturn(arg);

arg = hLib.getTflArgFromString('u1',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1width','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1height','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u2',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('y1',[dtype '*']);
arg.IOType = 'RTW_IO_OUTPUT';
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

hLib.addEntry( hEnt );
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function add_sse_mv_mult_entry_f32x4(hLib, implname, dtype, key, priority, srcPath, incPath, dimin1, dimin2, dimout, align)
e = IntelHostTFL.SSEMatrVectMulEntry_f32x4;
e = locSetEntryParam(e, key, priority, implname, srcPath, incPath);
locEntryMVMult(hLib, e, dtype, dimin1, dimin2, dimout, align);
end

function add_sse_mv_mult_entry_f64x2(hLib, implname, dtype, key, priority, srcPath, incPath, dimin1, dimin2, dimout, align)
e = IntelHostTFL.SSEMatrVectMulEntry_f64x2;
e = locSetEntryParam(e, key, priority, implname, srcPath, incPath);
locEntryMVMult(hLib, e, dtype, dimin1, dimin2, dimout, align);
end

% -------------------------------------------------------------------------
function locEntryMVMult( hLib, hEnt, dtype, in1Dims, in2Dims, outDims, align )

if isempty(hLib) || isempty( hEnt )
    return;
end

if(align > 0)
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    hEnt.Implementation.ArgumentDescriptor = des;
end

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix',...
        'Name',         'y1', ...
        'BaseType',     dtype, ...
        'IOType',       'RTW_IO_OUTPUT', ...
        'DimRange',     outDims);    

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u1', 'BaseType', dtype, 'DimRange', in1Dims);

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u2', 'BaseType', dtype, 'DimRange', in2Dims);

% Specify replacement function Signature
% sse_mv_mult(in1, row, t, in2, out)
arg = hLib.getTflArgFromString('y2','void');
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.Implementation.setReturn(arg);

arg = hLib.getTflArgFromString('u1',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1width','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1height','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u2',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('y1',[dtype '*']);
arg.IOType = 'RTW_IO_OUTPUT';
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

hLib.addEntry( hEnt );
end

%%
function add_sse_mm_mult_entry_f32x4(hLib, implname, dtype, key, priority, srcPath, incPath, dimin1, dimin2, dimout, align)
e = IntelHostTFL.SSEMatrMatrMulEntry_f32x4;
e = locSetEntryParam(e, key, priority, implname, srcPath, incPath);
locEntryMMMult(hLib, e, dtype, dimin1, dimin2, dimout, align);
end
function add_sse_mm_mult_entry_f64x2(hLib, implname, dtype, key, priority, srcPath, incPath, dimin1, dimin2, dimout, align)
e = IntelHostTFL.SSEMatrMatrMulEntry_f64x2;
e = locSetEntryParam(e, key, priority, implname, srcPath, incPath);
locEntryMMMult(hLib, e, dtype, dimin1, dimin2, dimout, align);
end

% -------------------------------------------------------------------------
function locEntryMMMult( hLib, hEnt, dtype, in1Dims, in2Dims, outDims, align )

if isempty(hLib) || isempty( hEnt )
    return;
end

if(align > 0)
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    hEnt.Implementation.ArgumentDescriptor = des;
end

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix',...
        'Name',         'y1', ...
        'BaseType',     dtype, ...
        'IOType',       'RTW_IO_OUTPUT', ...
        'DimRange',     outDims);    

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u1', 'BaseType', dtype, 'DimRange', in1Dims);

hEnt.createAndAddConceptualArg('RTW.TflArgMatrix', ...
                      'Name', 'u2', 'BaseType', dtype, 'DimRange', in2Dims);

% Specify replacement function Signature
% sse_mm_mult(in1, row, t, in2, col, out)
arg = hLib.getTflArgFromString('y2','void');
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.Implementation.setReturn(arg);

arg = hLib.getTflArgFromString('u1',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1width','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u1height','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u2',[dtype '*']);
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('u2height','integer', 0);
arg.PassByType = 'RTW_PASSBY_AUTO';
arg.Type.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

arg = hLib.getTflArgFromString('y1',[dtype '*']);
arg.IOType = 'RTW_IO_OUTPUT';
if align > 0
    des = RTW.ArgumentDescriptor;
    des.AlignmentBoundary = align;
    arg.Descriptor = des;
end
hEnt.Implementation.addArgument(arg);

hLib.addEntry( hEnt );
end


% -------------------------------------------------------------------------
function e = locSetEntryParam(e, key, priority, implname, srcPath, incPath)

e.setTflCOperationEntryParameters(...
    'Key',                         key, ...
    'Priority',                    priority, ...
    'ImplementationName',          implname, ...
    'ImplementationHeaderFile',    'mw_sse.h', ...
    'ImplementationSourceFile',    'mw_sse.c', ...
    'ImplementationHeaderPath',    incPath, ...
    'ImplementationSourcePath',    srcPath, ...
    'AdditionalCompileFlags',      {'-msse2'}, ...
    'SideEffects',                 true, ...
    'SaturationMode',              'RTW_SATURATE_UNSPECIFIED', ...
    'RoundingMode',                'RTW_ROUND_UNSPECIFIED', ...
    'GenCallback',                 'RTW.copyFileToBuildDir');
end