Part Number: TDA4VM
Other Parts Discussed in Thread: SYSBIOS
Tool/software: Code Composer Studio
Hi,
I am using the MMALIB_LINALG_matrixTranspose interface in mmalib, my psdk version is 06_02_00_21.
Below is my code
static void matTrans(int* out, int* in, int M, int N) {
MMALIB_bufParams2D_t aBuffer;
aBuffer.data_type = MMALIB_INT32;
aBuffer.dim_x = N;
aBuffer.dim_y = M;
aBuffer.stride_y = aBuffer.dim_x * MMALIB_sizeof(aBuffer.data_type);
MMALIB_bufParams2D_t bBuffer;
bBuffer.data_type = MMALIB_INT32;
bBuffer.dim_x = M;
bBuffer.dim_y = N;
bBuffer.stride_y = bBuffer.dim_x * MMALIB_sizeof(bBuffer.data_type);
MMALIB_LINALG_matrixTranspose_ixX_oxX_InitArgs initArgs;
//initArgs.funcStyle = MMALIB_FUNCTION_NATC;
initArgs.funcStyle = MMALIB_FUNCTION_OPTIMIZED;
int32_t handleSize = MMALIB_LINALG_matrixTranspose_ixX_oxX_getHandleSize(&initArgs);
MMALIB_kernelHandle kernelHandle = malloc(handleSize);
// Check that the parameters will generate a valid handle
MMALIB_STATUS initCheck = MMALIB_LINALG_matrixTranspose_ixX_oxX_init_checkParams(kernelHandle,
&aBuffer,
&bBuffer,
&initArgs);
printf("Init check = %d.\n", initCheck);
// Generate the handle
MMALIB_STATUS initStatus = MMALIB_LINALG_matrixTranspose_ixX_oxX_init(kernelHandle, &aBuffer, &bBuffer, &initArgs);
printf("Init status = %d.\n", initStatus);
// Check that the execute arguments are valid for execution
MMALIB_STATUS execCheck = MMALIB_LINALG_matrixTranspose_ixX_oxX_exec_checkParams(kernelHandle,
in,
out);
printf("Exec check = %d.\n", execCheck);
// Execute the kernel
MMALIB_STATUS execStatus = MMALIB_LINALG_matrixTranspose_ixX_oxX_exec(kernelHandle,
in,
out);
printf("Exec status = %d.\n", execStatus);
printf("MatMulIntrinsics done...\n");
free(kernelHandle);
}
int main(){
int m, n;
int M = 4;
int N = 4;
int matA[16] = { 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12,13,14, 15 };
int matB[16] = {0};
matTrans(&matB[0],&matA[0],M,N);
printf("matB = \n");
for ( m = 0; m < M; m++)
{
for ( n = 0; n < N; n++)
{
printf("%d ",matB[ m*N + n]);
}
printf("\n");
}
return 0;
}
If the funcStyle parameter is MMALIB_FUNCTION_NATC, the result is correct
[C7x_1 ] 25.874141 s: Init check = 0.
[C7x_1 ] 25.874162 s: Init status = 0.
[C7x_1 ] 25.874178 s: Exec check = 0.
[C7x_1 ] 25.874195 s: Exec status = 0.
[C7x_1 ] 25.874212 s: MatMulIntrinsics done...
[C7x_1 ] 25.874226 s: matB =
[C7x_1 ] 25.874242 s: 0 4 8 12
[C7x_1 ] 25.874256 s: 1 5 9 13
[C7x_1 ] 25.874271 s: 2 6 10 14
[C7x_1 ] 25.874286 s: 3 7 11 15
When the funcStyle parameter is set to MMALIB_FUNCTION_OPTIMIZED, the result is as follows
[C7x_1 ] 32.679648 s: Init check = 0.
[C7x_1 ] 32.679671 s: Init status = 0.
[C7x_1 ] 32.679687 s: Exec check = 0.
[C7x_1 ] 32.679705 s: Exec status = 0.
[C7x_1 ] 32.679723 s: MatMulIntrinsics done...
[C7x_1 ] 32.679738 s: matB =
[C7x_1 ] 32.679754 s: 0 0 0 0
[C7x_1 ] 32.679771 s: 0 0 0 0
[C7x_1 ] 32.679785 s: 0 0 0 0
[C7x_1 ] 32.679800 s: 0 0 0 0
How should I solve this problem?
Regards,
Henry