int main(void) { vbx_test_init(); #if 0 vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); const int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size; int N = VBX_SCRATCHPAD_SIZE/sizeof(vbx_mm_t)/8; #endif int TEST_LENGTH = TEST_ROWS*TEST_COLS; int NTAP_LENGTH = NTAP_ROWS*NTAP_COLS; int PRINT_COLS = min( TEST_COLS, MAX_PRINT_LENGTH ); int PRINT_ROWS = min( TEST_ROWS, MAX_PRINT_LENGTH ); double scalar_time, vector_time; int errors=0; vbx_mxp_print_params(); printf( "\nMatrix FIR test...\n" ); printf( "Matrix dimensions: %d,%d\n", TEST_ROWS, TEST_COLS ); vbx_mm_t *scalar_in = malloc( TEST_LENGTH*sizeof(vbx_mm_t) ); vbx_mm_t *vector_in = vbx_shared_malloc( TEST_LENGTH*sizeof(vbx_mm_t) ); int32_t *scalar_filt = malloc( NTAP_LENGTH*sizeof(int32_t) ); int32_t *vector_filt = vbx_shared_malloc( NTAP_LENGTH*sizeof(int32_t) ); vbx_mm_t *scalar_out = malloc( TEST_LENGTH*sizeof(vbx_mm_t) ); vbx_mm_t *vector_out = vbx_shared_malloc( TEST_LENGTH*sizeof(vbx_mm_t) ); VBX_T(test_zero_array)( scalar_out, TEST_LENGTH ); VBX_T(test_zero_array)( vector_out, TEST_LENGTH ); VBX_T(test_init_array)( scalar_in, TEST_LENGTH, 1 ); VBX_T(test_copy_array)( vector_in, scalar_in, TEST_LENGTH ); test_init_array_word( scalar_filt, NTAP_LENGTH, 1 ); test_copy_array_word( vector_filt, scalar_filt, NTAP_LENGTH ); VBX_T(test_print_matrix)( scalar_in, PRINT_ROWS, PRINT_COLS, TEST_COLS ); test_print_matrix_word( scalar_filt, NTAP_ROWS, NTAP_COLS, NTAP_COLS ); scalar_time = test_scalar( scalar_out, scalar_in, scalar_filt, TEST_ROWS, TEST_COLS, NTAP_ROWS, NTAP_COLS); VBX_T(test_print_matrix)( scalar_out, PRINT_COLS, PRINT_ROWS, TEST_COLS ); vector_time = test_vector( vector_out, vector_in, vector_filt, TEST_ROWS, TEST_COLS, NTAP_ROWS, NTAP_COLS, scalar_time ); VBX_T(test_print_matrix)( vector_out, PRINT_COLS, PRINT_ROWS, TEST_COLS ); int i; for(i=0; i<TEST_ROWS-NTAP_ROWS; i++){ errors += VBX_T(test_verify_array)( scalar_out+i*TEST_COLS, vector_out+i*TEST_COLS, TEST_COLS-NTAP_COLS ); } VBX_TEST_END(errors); return 0; }
int main(void) { vbx_test_init(); typedef vbx_word_t vbx_mm_t; vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); const int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size; int N = VBX_SCRATCHPAD_SIZE / sizeof(vbx_mm_t ); N = 20; int M = 20; int PRINT_LENGTH = N<MAX_PRINT_LENGTH ? N : MAX_PRINT_LENGTH ; // int PRINT_ROWS = PRINT_LENGTH; int PRINT_ROWS = M<MAX_PRINT_LENGTH ? N : MAX_PRINT_LENGTH; int PRINT_COLS = PRINT_LENGTH; double scalar_time, vector_time,vector2_time; int errors=0; vbx_mxp_print_params(); printf( "\nMatrix multiply test...\n" ); printf( "Matrix dimensions: %d,%d\n", N, M ); vbx_mm_t *scalar_in1 = (vbx_mm_t*)malloc( M*N*sizeof(vbx_mm_t ) ); vbx_mm_t *scalar_in2 = (vbx_mm_t*)malloc( M*N*sizeof(vbx_mm_t ) ); vbx_mm_t *scalar_out = (vbx_mm_t*)malloc( N*N*sizeof(vbx_mm_t ) ); vbx_mm_t *vector_in1 = (vbx_mm_t*)vbx_shared_malloc( M*N*sizeof(vbx_mm_t ) ); vbx_mm_t *vector_in2 = (vbx_mm_t*)vbx_shared_malloc( M*N*sizeof(vbx_mm_t ) ); vbx_mm_t *vector_out = (vbx_mm_t*)vbx_shared_malloc( N*N*sizeof(vbx_mm_t ) ); if ( scalar_in1 == NULL || scalar_in2 == NULL || scalar_out == NULL || vector_in1 == NULL || vector_in2 == NULL || vector_out == NULL ){ printf("Malloc failed\n"); VBX_TEST_END(1); return 0; } test_zero_array_word(scalar_out, N*N ); test_zero_array_word(vector_out, N*N ); test_init_array_word( scalar_in1, M*N, 1 ); test_copy_array_word( vector_in1, scalar_in1, M*N ); test_init_array_word( scalar_in2, M*N, 999 ); //scalar_mtx_xp_MN_word( vector_in2, scalar_in2, N, N ); test_copy_array_word( vector_in2, scalar_in2, M*N ); test_print_matrix_word( scalar_in1, PRINT_COLS, PRINT_ROWS, M ); test_print_matrix_word( scalar_in2, PRINT_ROWS, PRINT_COLS, N ); //change print sizes for outputs PRINT_ROWS=PRINT_COLS=N<PRINT_LENGTH?N:PRINT_LENGTH; scalar_time = test_scalar( scalar_out, scalar_in1, N, M, scalar_in2, M, N); test_print_matrix_word( scalar_out, PRINT_COLS, PRINT_ROWS, N ); vector_time = test_vector( vector_out, vector_in1, N, M, vector_in2, M, N, scalar_time ); test_print_matrix_word( vector_out, PRINT_COLS, PRINT_ROWS, N ); errors += test_verify_array_word( scalar_out, vector_out, N*N); vector2_time = test_vector_trans( vector_out, vector_in1, N, M, vector_in2, M, N, scalar_time ); test_print_matrix_word( vector_out, PRINT_COLS, PRINT_ROWS, N ); errors += test_verify_array_word( scalar_out, vector_out, N*N); vector2_time = test_vector_sp( vector_out, vector_in1, N, M, vector_in2, M, N, scalar_time ); test_print_matrix_word( vector_out, PRINT_COLS, PRINT_ROWS, N ); errors += test_verify_array_word( scalar_out, vector_out, N*N); vbx_shared_free(vector_out); vbx_shared_free(vector_in2); vbx_shared_free(vector_in1); free(scalar_out); free(scalar_in2); free(scalar_in1); //errors += orig_test(); VBX_TEST_END(errors); return 0; }