core_matrix.c | |
Description | Matrix manipulation benchmark |
Functions | |
core_bench_matrix | Benchmark function |
matrix_test | Perform matrix manipulation. |
matrix_sum | Calculate a function that depends on the values of elements in the matrix. |
matrix_mul_const | Multiply a matrix by a constant. |
matrix_add_const | Add a constant value to all elements of a matrix. |
matrix_mul_vect | Multiply a matrix by a vector. |
matrix_mul_matrix | Multiply a matrix by a matrix. |
matrix_mul_matrix_bitextract | Multiply a matrix by a matrix, and extract some bits from the result. |
Matrix manipulation benchmark
This very simple algorithm forms the basis of many more complex algorithms.
The tight inner loop is the focus of many optimizations (compiler as well as hardware based) and is thus relevant for embedded processing.
NxN Matrix A | initialized with small values (upper 3/4 of the bits all zero). |
NxN Matrix B | initialized with medium values (upper half of the bits all zero). |
NxN Matrix C | used for the result. |
The actual values for A and B must be derived based on input that is not available at compile time.
ee_u16 core_bench_matrix( mat_params * p, ee_s16 seed, ee_u16 crc )
Benchmark function
Iterate matrix_test N times, changing the matrix values slightly by a constant amount each time.
ee_s16 matrix_test( ee_u32 N, MATRES * C, MATDAT * A, MATDAT * B, MATDAT val )
Perform matrix manipulation.
N | Dimensions of the matrix. |
C | memory for result matrix. |
A | input matrix |
B | operator matrix (not changed during operations) |
A CRC value that captures all results calculated in the function. In particular, crc of the value calculated on the result matrix after each step by matrix_sum.
1 | Add a constant value to all elements of a matrix. |
2 | Multiply a matrix by a constant. |
3 | Multiply a matrix by a vector. |
4 | Multiply a matrix by a matrix. |
5 | Add a constant value to all elements of a matrix. |
After the last step, matrix A is back to original contents.
ee_s16 matrix_sum( ee_u32 N, MATRES * C, MATDAT clipval )
Calculate a function that depends on the values of elements in the matrix.
For each element, accumulate into a temporary variable.
As long as this value is under the parameter clipval, add 1 to the result if the element is bigger then the previous.
Otherwise, reset the accumulator and add 10 to the result.
Benchmark function
ee_u16 core_bench_matrix( mat_params * p, ee_s16 seed, ee_u16 crc )
Perform matrix manipulation.
ee_s16 matrix_test( ee_u32 N, MATRES * C, MATDAT * A, MATDAT * B, MATDAT val )
Calculate a function that depends on the values of elements in the matrix.
ee_s16 matrix_sum( ee_u32 N, MATRES * C, MATDAT clipval )
Multiply a matrix by a constant.
void matrix_mul_const( ee_u32 N, MATRES * C, MATDAT * A, MATDAT val )
Add a constant value to all elements of a matrix.
void matrix_add_const( ee_u32 N, MATDAT * A, MATDAT val )
Multiply a matrix by a vector.
void matrix_mul_vect( ee_u32 N, MATRES * C, MATDAT * A, MATDAT * B )
Multiply a matrix by a matrix.
void matrix_mul_matrix( ee_u32 N, MATRES * C, MATDAT * A, MATDAT * B )
Multiply a matrix by a matrix, and extract some bits from the result.
void matrix_mul_matrix_bitextract( ee_u32 N, MATRES * C, MATDAT * A, MATDAT * B )