TSmallMatrixMultiply Class

Header: Dew.Math/MtxVec.h · Cross-compiler
tObjectTSmallMatrixMultiply

class TSmallMatrixMultiply : public tObject;

Provides interface for multiplying small matrices by using the lapack's dgemm api standard.)

The matrix multiplication code is generated on the fly to achieve maximum possible performance. Additionally all the error checking on each consecutive call is also absent. This is most usefull, when the matrices to be multiplied are very small: 2x2 or 3x3, (100x) but there are still considerable benefits up to size 50x50 (1.3x) and more.

Typically this object would be created, then Init method is to be called and finally, one of the six Mul methods can be called multiple times.The class provides four variants of Multiply methods:

  • Mul(a,b,c: TMtx);
  • Mul;
  • MulKernel
  • MulKernelFloat, MulKernelDouble, MulKernelComplexFloat, MulKernelComplexDouble

It is most safe to use the first variant. Performance will increase with the parameterless Mul method (2x) and best performance can be obtained with the third variant (3x). Only switch to using the third variant when you are confident, that your algorithm works correctly.

Please note that

TMtx.Mul(A,B);

will use object cache to store JIT-ed kernels up to user specified matrix size for square matrices. The default limit is set at size 32x32. The kernel will be created on first call.

Destructors

NameDescription
~TSmallMatrixMultiplyThe object is required to be freed manually.

Properties

NameTypeDescription
cColsintField computed by Init method. Holds the row count of the matrix to hold the result.
cRowsintField computed by Init method. Holds the row count of the matrix to hold the result.

Methods

NameDescription
FreeKernelFrees the internally jitted kernel
Init (4)Initialize matrix multiplication
Mul (2)Performs matrix multiplication optimized for small matrices

Fields

NameTypeDescription
ApintPtr
bpintPtr
calphaTSCplx
cbetaTSCplx
cpintPtr
faColsint
faOpTMtxOperation
faRowsint
fbColsint
fbOpTMtxOperation
fbRowsint
fcColsint
fcRowsint
FloatPrecisionTMtxFloatPrecisionProvides interface for multiplying small matrices by using the lapack's dgemm api standard.)
IsInitbool
JitKernelintPtr
jitterintPtrJitted code pointer.
MulKernelTgemm_jit_kernel_tpFunction pointer to the jitted multiplication kernel.
MulKernelComplexDoubleTzgemm_jit_kernel_tFunction pointer to the complex double precision jitted multiplication kernel.
MulKernelComplexFloatTcgemm_jit_kernel_tFunction pointer to the complex single precision jitted multiplication kernel.
MulKernelDoubleTdgemm_jit_kernel_tFunction pointer to the double precision jitted multiplication kernel.
MulKernelFloatTsgemm_jit_kernel_tFunction pointer to the single precision jitted multiplication kernel.
zalphaTCplx
zbetaTCplx