double test_vector_sp(vbx_mm_t *vector_out, vbx_mm_t *vector_in1, int IN1ROWS, int IN1COLS, vbx_mm_t *vector_in2, int IN2ROWS, int IN2COLS, double scalar_time ) { typedef vbx_mm_t vbx_sp_t; int retval=-1; vbx_timestamp_t time_start, time_stop; printf( "\nExecuting MXP matrix multiply... src1[%dx%d] src2[%dx%d]\n",IN1ROWS, IN1COLS,IN2ROWS, IN2COLS ); vbx_timestamp_start(); time_start = vbx_timestamp(); vbx_sp_push(); vbx_sp_t* v_in1=(vbx_sp_t*)vbx_sp_malloc(sizeof(vbx_sp_t)*IN1ROWS*IN1COLS); vbx_sp_t* v_in2=(vbx_sp_t*)vbx_sp_malloc(sizeof(vbx_sp_t)*IN2ROWS*IN2COLS); vbx_sp_t* v_out=(vbx_sp_t*)vbx_sp_malloc(sizeof(vbx_sp_t)*IN1ROWS*IN2COLS); if(v_out!=NULL){ vbx_dma_to_vector(v_in1,vector_in1,sizeof(vbx_sp_t)*IN1ROWS*IN1COLS); vbx_dma_to_vector(v_in2,vector_in2,sizeof(vbx_sp_t)*IN2ROWS*IN2COLS); retval = vbw_mtx_mul( v_out, v_in1, IN1ROWS, IN1COLS, v_in2, IN2ROWS, IN2COLS ); vbx_dma_to_host(vector_out,v_out,sizeof(vbx_sp_t)*IN1ROWS*IN2COLS); vbx_sync(); }else{ printf("not enough sp space for sp test"); } time_stop = vbx_timestamp(); printf( "...done. retval:0x%08X\n", retval ); return vbx_print_vector_time( time_start, time_stop, scalar_time ); }
int dma_bandwidth_test() { const int num_iter = 64; vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); int scratchpad_size = this_mxp->scratchpad_size; uint8_t *buf = vbx_shared_malloc(scratchpad_size); vbx_ubyte_t *v_buf = vbx_sp_malloc(scratchpad_size); vbx_timestamp_t time_start, time_stop; int i; int len; int to_host; int errors = 0; vbx_mxp_print_params(); // dma_alignment_bytes gives DMA master data bus width in bytes. double bytes_per_sec = \ (((double) this_mxp->core_freq) * this_mxp->dma_alignment_bytes); double max_megabytes_per_sec = bytes_per_sec/(1024*1024); printf("\nMax available bandwidth = %s Megabytes/s\n", vbx_eng(max_megabytes_per_sec, 4)); printf("\n"); for (to_host = 0; to_host < 2; to_host++) { for (len = 32; len <= scratchpad_size ; len *= 2) { printf("DMA %s, %d bytes\n", to_host ? "write" : "read", len); vbx_timestamp_start(); if (to_host) { time_start = vbx_timestamp(); for (i = 0; i < num_iter; i++) { vbx_dma_to_host(buf, v_buf, len); } vbx_sync(); time_stop = vbx_timestamp(); } else { time_start = vbx_timestamp(); for (i = 0; i < num_iter; i++) { vbx_dma_to_vector(v_buf, buf, len); } vbx_sync(); time_stop = vbx_timestamp(); } print_dma_bandwidth(time_start, time_stop, len, num_iter, max_megabytes_per_sec); printf("\n"); } printf("\n"); } vbx_shared_free(buf); vbx_sp_free(); return errors; }
double test_scalar( vbx_mm_t *scalar_out, vbx_mm_t *scalar_in1, int IN1ROWS, int IN1COLS, vbx_mm_t *scalar_in2, int IN2ROWS, int IN2COLS ) { vbx_timestamp_t time_start, time_stop; printf( "\nExecuting scalar matrix multiply...\n" ); vbx_timestamp_start(); time_start = vbx_timestamp(); vbw_mtx_mul_scalar_ext_word( scalar_out, scalar_in1, IN1ROWS, IN1COLS, scalar_in2, IN2ROWS, IN2COLS ); time_stop = vbx_timestamp(); printf( "...done.\n" ); return vbx_print_scalar_time( time_start, time_stop ); }
double test_scalar( vbx_mm_t *scalar_out, vbx_mm_t *scalar_in1, vbx_mm_t *scalar_in2, int N ) { vbx_timestamp_t time_start, time_stop; printf( "\nExecuting scalar add...\n" ); vbx_timestamp_start(); time_start = vbx_timestamp(); VBX_T(scalar_vec_add)( scalar_out, scalar_in1, scalar_in2, N ); time_stop = vbx_timestamp(); printf( "...done\n" ); return vbx_print_scalar_time( time_start, time_stop ); }
double test_scalar( vbx_mm_t *scalar_out, vbx_mm_t *scalar_in, int32_t *coeffs, int test_row, int test_col, int ntaps_row, int ntaps_col) { vbx_timestamp_t time_start, time_stop; printf("\nExecuting scalar matrix FIR...\n"); vbx_timestamp_start(); time_start = vbx_timestamp(); VBX_T(scalar_mtx_2Dfir)( scalar_out, scalar_in, coeffs, test_row, test_col, ntaps_row, ntaps_col ); time_stop = vbx_timestamp(); printf( "...done\n" ); return vbx_print_scalar_time( time_start, time_stop ); }
double test_scalar_power( vbx_word_t *scalar_out, vbx_word_t *scalar_in1, vbx_word_t *scalar_in2, int N ) { vbx_timestamp_t time_start, time_stop; printf("\nExecuting scalar power..."); vbx_timestamp_start(); time_start = vbx_timestamp(); scalar_vec_power_word( scalar_out, scalar_in1, scalar_in2, N); time_stop = vbx_timestamp(); printf( "...done\n" ); return vbx_print_scalar_time(time_start, time_stop); }
double test_scalar( vbx_mm_t *scalar_out, vbx_mm_t *scalar_sample, vbx_mm_t *scalar_coeffs) { vbx_timestamp_t time_start, time_stop; printf("\nExecuting scalar vector FIR...\n"); vbx_timestamp_start(); time_start = vbx_timestamp(); VBX_T(scalar_vec_fir)( scalar_out, scalar_sample, scalar_coeffs, SAMP_SIZE, NTAPS ); time_stop = vbx_timestamp(); printf("...done\n"); return vbx_print_scalar_time( time_start, time_stop ); }
double test_vector_2d( vbx_mm_t *vector_out, vbx_mm_t *sample, vbx_mm_t *coeffs, double scalar_time ) { vbx_timestamp_t time_start, time_stop; printf("\nExecuting MXP vector FIR with Accum 2D....\n"); vbx_timestamp_start(); time_start = vbx_timestamp(); VBX_T(vbw_vec_fir_2d)( vector_out, sample, coeffs, SAMP_SIZE, NTAPS ); time_stop = vbx_timestamp(); printf("...done\n"); return vbx_print_vector_time( time_start, time_stop, scalar_time ); }
double test_vector( vbx_mm_t *out, vbx_mm_t *in, int32_t *coeffs, int test_row, int test_col, int ntaps_row, int ntaps_col, double scalar_time ) { vbx_timestamp_t time_start, time_stop; printf( "\nExecuting MXP matrix FIR...\n" ); vbx_timestamp_start(); time_start = vbx_timestamp(); VBX_T(vbw_mtx_2Dfir)( out, in, coeffs, test_row, test_col, ntaps_row, ntaps_col ); time_stop = vbx_timestamp(); printf( "...done\n" ); return vbx_print_vector_time( time_start, time_stop, scalar_time ); }
double test_vector_transpose( vbx_mm_t *vector_out, vbx_mm_t *sample, vbx_mm_t *coeffs, double scalar_time ) { int retval; vbx_timestamp_t time_start, time_stop; printf("\nExecuting MXP vector transpose FIR.... \n"); vbx_timestamp_start(); time_start = vbx_timestamp(); retval = VBX_T(vbw_vec_fir_transpose_ext)( vector_out, sample, coeffs, SAMP_SIZE, NTAPS ); time_stop = vbx_timestamp(); printf("...done retval:%X\n", retval); return vbx_print_vector_time( time_start, time_stop, scalar_time ); }
double test_vector_trans(vbx_mm_t *vector_out, vbx_mm_t *vector_in1, int IN1ROWS, int IN1COLS, vbx_mm_t *vector_in2, int IN2ROWS, int IN2COLS, double scalar_time ) { int retval; vbx_timestamp_t time_start, time_stop; printf( "\nExecuting MXP matrix multiply... src1[%dx%d] src2[%dx%d]\n",IN1ROWS, IN1COLS,IN2ROWS, IN2COLS ); vbx_timestamp_start(); time_start = vbx_timestamp(); retval = vbw_mtx_mm_trans_ext( vector_out, vector_in1, IN1ROWS, IN1COLS, vector_in2, IN2ROWS, IN2COLS ); time_stop = vbx_timestamp(); printf( "...done. retval:0x%08X\n", retval ); return vbx_print_vector_time( time_start, time_stop, scalar_time ); }
double test_vector_ext( vbx_mm_t *out, vbx_mm_t *in, int N, double scalar_time ) { int retval; vbx_timestamp_t time_start, time_stop; printf( "\nExecuting vector copy (ext)...\n" ); vbx_timestamp_start(); time_start = vbx_timestamp(); retval = VBX_T(vbw_vec_copy_ext)( out, in, N ); vbx_sync(); time_stop = vbx_timestamp(); printf( "...done. retval: %X\n", retval ); return vbx_print_vector_time(time_start, time_stop, scalar_time); }
double test_vector( vbx_sp_t *v_out, vbx_sp_t *v_in1, vbx_sp_t *v_in2, int N, double scalar_time ) { int retval; vbx_timestamp_t time_start, time_stop; printf( "\nExecuting MXP vector add...\n" ); vbx_timestamp_start(); time_start = vbx_timestamp(); retval = VBX_T(vbw_vec_add)( v_out, v_in1, v_in2, N ); vbx_sync(); time_stop = vbx_timestamp(); printf( "...done. retval: %X\n", retval ); return vbx_print_vector_time(time_start, time_stop, scalar_time ); }
int main() { unsigned int errors = 0; vbx_test_init(); vbx_timestamp_start(); // Requires > 64KB scratch: // printf(VBX_EXPAND_AND_QUOTE(VBX_CPU_DCACHE_LINE_SIZE)); errors += VBX_T(vbw_vec_reverse_test)(); errors += VBX_T(vbw_vec_reverse_test_mm)(); VBX_TEST_END(errors); return 0; }
double test_vector_power( vbx_word_t *vector_out, vbx_word_t *vector_in1, vbx_word_t *vector_in2, int N, double scalar_time ) { int retval; vbx_timestamp_t time_start, time_stop; printf("\nExecuting MXP vector software power..."); vbx_word_t *v_out = vbx_sp_malloc( N*sizeof(vbx_word_t) ); vbx_word_t *v_in1 = vbx_sp_malloc( N*sizeof(vbx_word_t) ); vbx_word_t *v_in2 = vbx_sp_malloc( N*sizeof(vbx_word_t) ); vbx_dma_to_vector( v_in1, vector_in1, N*sizeof(vbx_word_t) ); vbx_dma_to_vector( v_in2, vector_in2, N*sizeof(vbx_word_t) ); vbx_timestamp_start(); time_start = vbx_timestamp(); retval = vbw_vec_power_word( v_out, v_in1, v_in2, N ); vbx_sync(); time_stop = vbx_timestamp(); vbx_dma_to_host( vector_out, v_out, N*sizeof(vbx_word_t) ); vbx_sync(); printf("done. retval:%X\n",retval); return vbx_print_vector_time(time_start, time_stop, scalar_time); }
int main(void) { vbx_timestamp_t time_start, time_stop; double scalar_time, vector_time; input_pointer img1; input_pointer img2; input_pointer sc_img1; input_pointer sc_img2; output_pointer scalar_out; output_pointer vector_out; int i,j; int total_errors = 0; vbx_test_init(); vbx_mxp_print_params(); img1 = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type) ); img2 = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type) ); vector_out = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(output_type) ); sc_img1 = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type) ); sc_img2 = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type) ); scalar_out = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(output_type) ); init_img( img1, img2 ); init_img( sc_img1, sc_img2 ); vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); const int VBX_VECTOR_BYTE_LANES = this_mxp->vector_lanes * sizeof(int); printf("\n"); printf("Num of byte lanes: %d\n", VBX_VECTOR_BYTE_LANES); printf("Initialized data\n\n"); printf("Executing Scalar Image Blend...\n"); vbx_timestamp_start(); time_start = vbx_timestamp(); scalar_blend( scalar_out, sc_img1, sc_img2, NUM_OF_ROWS, NUM_OF_COLUMNS, CONST_BLEND ); time_stop = vbx_timestamp(); printf("Finished Scalar Image Blend\n"); scalar_time = vbx_print_scalar_time(time_start, time_stop); printf("\nExecuting Vector Image Blend...\n"); vbx_timestamp_start(); time_start = vbx_timestamp(); vector_blend( vector_out, img1, img2, NUM_OF_ROWS, NUM_OF_COLUMNS, CONST_BLEND); time_stop = vbx_timestamp(); printf("Finished Vector Image Blend\n"); vector_time = vbx_print_vector_time(time_start, time_stop, scalar_time); int errors = 0; for( j=0; j<NUM_OF_ROWS; j++ ) { for( i = 0; i < NUM_OF_COLUMNS; i++ ) { if( vector_out[j*NUM_OF_COLUMNS+i] != scalar_out[j*NUM_OF_COLUMNS+i] ) { if(errors < 5) printf( "\nFail at sample [%3d,%3d]. Scalar: %3d Vector: %3d Img1: %3d Img2: %3d", j, i, scalar_out[j*NUM_OF_COLUMNS+i], vector_out[j*NUM_OF_COLUMNS+i], img1[j*NUM_OF_COLUMNS+i], img2[j*NUM_OF_COLUMNS+i] ); errors++; } } } printf("\n%d errors\n", errors); total_errors += errors; VBX_TEST_END(total_errors); return 0; }
int main(void) { vbx_timestamp_t time_start, time_stop; double scalar_time, vbx_time, vbx_time_masked; int i, j, k, l, m, n; int errors = 0; vbx_test_init(); vbx_mxp_print_params(); pixel *input, *scalar_input, *vbx_input, *vbx_input_masked; uint16_t *scalar_short; input = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_input = (pixel *)vbx_remap_cached(input, IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_short = (uint16_t *)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(uint16_t)); vbx_input = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); vbx_input_masked = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); #if UNIT unsigned short *img, *vbx_img; unsigned int *iImg, *vbx_iImg; unsigned int *iiImg, *vbx_iiImg; img = (unsigned short*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned short)); vbx_img = (unsigned short*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned short)); iImg = (unsigned int*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); vbx_iImg = (unsigned int*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); iiImg = (unsigned int*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); vbx_iiImg = (unsigned int*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); #endif//UNIT printf("Resolution = %dx%d\n", IMAGE_WIDTH, IMAGE_HEIGHT); printf("Initializing data\n"); vbx_timestamp_start(); for(l = 0; l < 1; l++){ char *src; char *sdst; char *vdst; char *mdst; if(l == 0){ load_lenna(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_lenna(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_lenna(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nLenna\n"); src = "lenna"; sdst = "s_lenna"; vdst = "v_lenna"; mdst = "m_lenna"; }else if(l == 1){ load_ms(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_ms(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_ms(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nMicrosoft\n"); src = "ms"; sdst = "s_ms"; vdst = "v_ms"; mdst = "m_ms"; }else if(l == 2){ load_blank(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_blank(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_blank(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nblank\n"); src = "blank"; sdst = "s_blank"; vdst = "v_blank"; mdst = "m_blank"; } #if UNIT int window = 20; int log=0; while(((window/3)>>log) >= 2) log++; #if LUT_CI /* errors += compare_vbx_lut_to_vbx_lut_ci(1024, MAX_PRINT_ERRORS); */ #endif #if LBP_CI errors += compare_vbx_lbp_ci_to_scalar_patterns(vbx_img, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #endif errors += compare_scalar_rgb2luma_to_vbw_rgb2luma16(img, vbx_img, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, MAX_PRINT_ERRORS); /* errors += compare_LBPRestrictedSums_to_test_scalar_sums_byte(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); */ /* errors += compare_LBPRestrictedSums2_to_test_scalar_sums_half(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); */ /* errors += compare_ScalarLBPRestrictedSums_to_test_scalar_sums_half(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); */ /* errors += compare_ScalarLBPRestrictedPatterns_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); */ /* errors += compare_LBPRestrictedPatterns2_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); */ errors += compare_LBPRestricted_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #if 0 /* overflow issues -- using bytes changes lbp pattern */ errors += compare_LBPRestrictedPatterns_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* requires SKIP_INTEGRALS 0 */ errors += compare_gen_integrals_to_vector_get_img(img, iImg, iiImg, vbx_img, vbx_iImg, vbx_iiImg, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* currently last values have errors if the scaled images size is not an integer, width * f/ (f+1) */ errors += compare_scalar_BLIP2_to_vector_BLIP(img, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* redundant test, compare to test_scalar_patterns instead */ errors += compare_ScalarLBPRestrictedPatterns_to_SATBinaryPattern(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_SATBinaryPattern_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #endif errors += compare_LBPPassStage_to_restricted(vbx_img, log, face_lbp[0], window, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #else // UNIT #if PRINT print_python_pixel(scalar_input, src, IMAGE_WIDTH, IMAGE_HEIGHT); #endif time_start = vbx_timestamp(); scalar_rgb2luma(scalar_short, input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH); scalar_face_detect_luma(scalar_short, input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, sdst); time_stop = vbx_timestamp(); scalar_time = vbx_print_scalar_time(time_start, time_stop); #if PRINT print_python_pixel(scalar_input, sdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif printf("\nVector"); time_start = vbx_timestamp(); vector_face_detect((pixel *)vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, 0, vdst); time_stop = vbx_timestamp(); vbx_time = vbx_print_vector_time(time_start, time_stop, scalar_time); #if PRINT print_python_pixel(vbx_input, vdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif printf("\nVector Masked"); time_start = vbx_timestamp(); vector_face_detect((pixel *)vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, 1, mdst); time_stop = vbx_timestamp(); vbx_time_masked = vbx_print_vector_time(time_start, time_stop, scalar_time); #if PRINT print_python_pixel(vbx_input_masked, mdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif /* errors += match_array_pixel(input, vbx_input, "vector", IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS, 0); */ /* errors += match_array_pixel(input, vbx_input_masked, "masked", IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS, 0); */ errors += match_array_pixel(vbx_input, vbx_input_masked, "masked", IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS, 0); #endif // UNIT } VBX_TEST_END(errors); return errors; }
int main_tile() { int i, j, k, l, base, block_num; int x, y; int time_start, time_stop; unsigned int cycles; double vbx_time, scalar_time; int wrong; int total_errors = 0; //all of the initialization can be hard coded without any computation vbx_mtx_fdct_t *v = vbx_mtx_fdct_init( coeff_v, image ); vbx_timestamp_start(); printf("\nGenerating initial data...\n"); dt *image = (dt *) malloc( IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(dt) ); GenerateRandomImage( image, IMAGE_WIDTH, IMAGE_HEIGHT, 0/*seed*/ ); // Allocate memory to store results. // Results are computed BIGTILE_SIZE halfwords at a time. const int BIGTILE_SIZE = NUM_TILE_X * NUM_TILE_Y * DCT_SIZE; dt *block_s = malloc( BIGTILE_SIZE * sizeof(dt) ); dt *block_v = (dt *) vbx_shared_malloc( BIGTILE_SIZE * sizeof(dt) ); dt *coeff_v = (dt *) vbx_shared_malloc( BIGTILE_SIZE * sizeof(dt) ); //Make an uncached 1D version of the coeff matrix for (i = 0; i < NUM_TILE_Y; i++) { // row for (j = 0; j < BLOCK_SIZE; j++) { // row for (k = 0; k < NUM_TILE_X; k++) { // col for (l = 0; l < BLOCK_SIZE; l++) { // col coeff_v[i*NUM_TILE_X*DCT_SIZE + j*DCT_SIZE + k*BLOCK_SIZE + l] = cs[j][l]; } } } } #ifdef DEBUG printf("input matrix is:\n"); for (i = 0; i < BLOCK_SIZE; i++) { base = i * BLOCK_SIZE; for (j = 0; j < BLOCK_SIZE; j++) { printf("%d ", (int) block_s[base + j]); } printf("\n"); } #endif printf("\nRunning DCT...\n"); time_start = vbx_timestamp(); for( y = 0; y < IMG_DOWN; y++ ) { for( x = 0; x < IMG_ACROSS; x++ ) { vbx_mtx_fdct_scalar( block_s, (dt*)cs, image, x/*start_x*/, y/*start_y*/, NUM_TILE_X, NUM_TILE_Y ); } } time_stop = vbx_timestamp(); cycles = time_stop - time_start; scalar_time = (double) cycles; scalar_time /= (double) vbx_timestamp_freq(); scalar_time *= 1000.0; //ms vbx_timestamp_t mxp_cycles = vbx_mxp_cycles(cycles); printf("%dx%d Block Size\n", BLOCK_SIZE, BLOCK_SIZE); printf("Finished, scalar CPU took %0.3f ms \n", scalar_time); printf(" CPU Cycles: %d\n", (int) mxp_cycles); printf(" CPU Cycles per block: %f\n", mxp_cycles / ((double) (NUM_BLOCKS))); vbx_sync(); // wait for image to be prefetched time_start = vbx_timestamp(); for( y = 0; y < IMG_DOWN; y++ ) { for( x = 0; x < IMG_ACROSS; x++ ) { vbx_mtx_fdct( v, block_v, image, x/*start_x*/, y/*start_y*/, IMG_ACROSS-1,IMG_DOWN-1,NUM_TILE_X, NUM_TILE_Y ); } } time_stop = vbx_timestamp(); cycles = time_stop - time_start; vbx_time = (double) cycles; vbx_time /= (double) vbx_timestamp_freq(); vbx_time *= 1000.0; //ms mxp_cycles = vbx_mxp_cycles(cycles); printf("Finished, MXP took %0.3f ms \n", vbx_time); printf(" CPU Cycles: %d\n", (int) mxp_cycles); printf(" CPU Cycles per block: %f\n", mxp_cycles / ((double) (NUM_BLOCKS))); printf(" Speedup: %f\n", scalar_time / vbx_time); vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); double vbx_mbps = (double) (NUM_BLOCKS) * 1000 / vbx_time; // blocks per second printf("V%d@%dMHz: %dx%d tile, %dx%d blocks, %f blocks/s, %f megapixel/s\n", this_mxp->vector_lanes, this_mxp->core_freq / 1000000, NUM_TILE_Y, NUM_TILE_X, BLOCK_SIZE, BLOCK_SIZE, vbx_mbps, (vbx_mbps * DCT_SIZE) / 1000000); printf("\nChecking results...\n"); wrong = 0; for (block_num = 0; block_num < NUM_BLOCKS; block_num++) { for (i = 0; i < BLOCK_SIZE; i++) { base = i * BLOCK_SIZE; for (j = 0; j < BLOCK_SIZE; j++) { if (block_s[block_num * DCT_SIZE + base + j] != block_v[block_num * DCT_SIZE + base + j]) { if (wrong < 5) { printf("\nError at %d [%d,%d], result is %d, should be %d\n", block_num, i, j, (int) block_v[block_num * DCT_SIZE + base + j], (int) block_s[block_num * DCT_SIZE + base + j]); } wrong++; } } } } printf("wrong is %d\n\n", wrong); total_errors += wrong; free(block_s); vbx_shared_free(block_v); vbx_shared_free(coeff_v); vbx_mtx_fdct_free( v ); VBX_TEST_END(total_errors); return (0); }
int compare_scalar_BLIP2_to_vector_BLIP(unsigned short* img, pixel* vbx_input, int width, int height, int max_print_errors, int scale_factor) { int j, errors = 0; int scaled_width, scaled_height; /* scale facetor v/v+1, v is between 1-10 */ scaled_width = width*scale_factor/(scale_factor+1); scaled_height= height*scale_factor/(scale_factor+1); unsigned short *scaled_img, *vbx_img, *vbx_scaled_img; unsigned char *vbx_img8, *vbx_scaled_img8; unsigned int *iImg, *iiImg, *vbx_iImg, *vbx_iiImg; scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short)); iImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int)); iiImg = (unsigned int*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned int)); vbx_scaled_img = (unsigned short*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned short)); vbx_img = (unsigned short*)vbx_shared_malloc(width*height*sizeof(unsigned short)); vbx_img8 = (unsigned char*)vbx_shared_malloc(width*height*sizeof(unsigned char)); vbx_scaled_img8 = (unsigned char*)vbx_shared_malloc(scaled_width*scaled_height*sizeof(unsigned char)); vbx_iImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int)); vbx_iiImg = (unsigned int*)vbx_shared_malloc(width*height*sizeof(unsigned int)); #if 0 scalar_BLIP2(img, height, width, scaled_img, scaled_height, scaled_width, scale_factor); #else float percent = 1.0 * (scale_factor+1) / scale_factor; scalar_BLIP(img, height, width, scaled_img, scaled_height, scaled_width, &percent); #endif gen_integrals(scaled_img, iImg, iiImg, scaled_width, scaled_height); vector_get_img(vbx_img, vbx_iImg, vbx_iiImg, vbx_input, 1, width, height, width, 1); vector_BLIP(vbx_img, height, width, vbx_scaled_img, vbx_iImg, vbx_iiImg, scaled_height, scaled_width, scale_factor, 1); vector_get_img8(vbx_img8, vbx_input, 1, width, height, width); /* vector_BLIP8(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor); */ vbx_timestamp_start(); vbx_timestamp_t time_start, time_stop; double vbx_time; time_start = vbx_timestamp(); #if 1 vector_BLIP8F3(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor); #else vector_BLIP8F2(vbx_img8, height, width, vbx_scaled_img8, scaled_height, scaled_width, scale_factor); #endif time_stop = vbx_timestamp(); vbx_time = vbx_print_vector_time(time_start, time_stop, 0.0); /* test greyscale image */ for (j = 0; j < height; j++) { errors += match_array_half(img+j*width, vbx_img+j*width, "greyscale", width, 1, 0, max_print_errors, j); if(errors > max_print_errors) { max_print_errors = 0; } } /* test scaled image */ for (j = 0; j < scaled_height; j++) { errors += match_array_half(scaled_img+j*scaled_width, vbx_scaled_img+j*scaled_width, "scaled greyscale", scaled_width, 1, 1, max_print_errors, j); if(errors > max_print_errors) { max_print_errors = 0; } } for (j = 0; j < scaled_height; j++) { errors += match_array_half_byte(scaled_img+j*scaled_width, vbx_scaled_img8+j*scaled_width, "scaled greyscale8", scaled_width, 1, 1, max_print_errors, j); if(errors > max_print_errors) { max_print_errors = 0; } } #if 0 /* test scaled_integral image */ for (j = 0; j < scaled_height; j++) { errors += match_array_word(iImg+j*scaled_width, vbx_iImg+j*scaled_width, "scaled integral", scaled_width, 1, 0, max_print_errors, j); if(errors > max_print_errors) { max_print_errors = 0; } } /* test scaled squared integral image */ for (j = 0; j < scaled_height; j++) { errors += match_array_word(iiImg+j*scaled_width, vbx_iiImg+j*scaled_width, "scaled squared", scaled_width, 1, 0, max_print_errors, j); if(errors > max_print_errors) { max_print_errors = 0; } } #endif /* test scaled_integral image */ return errors; }
int main(void) { vbx_timestamp_t time_start, time_stop; double scalar_time, vbx_time, vbx_time_masked; int i, j, k, l, m, n; int errors = 0; vbx_test_init(); vbx_mxp_print_params(); pixel *input, *scalar_input, *vbx_input, *vbx_input_masked; uint16_t *scalar_short; input = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_input = (pixel *)vbx_remap_cached(input, IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_short = (uint16_t *)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(uint16_t)); vbx_input = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); vbx_input_masked = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); #if UNIT unsigned char *vbx_img8; unsigned short *img, *vbx_img; unsigned int *iImg, *vbx_iImg; unsigned int *iiImg, *vbx_iiImg; img = (unsigned short*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned short)); vbx_img = (unsigned short*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned short)); vbx_img8 = (unsigned char*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned char)); iImg = (unsigned int*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); vbx_iImg = (unsigned int*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); iiImg = (unsigned int*)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); vbx_iiImg = (unsigned int*)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned int)); #endif//UNIT printf("Resolution = %dx%d\n", IMAGE_WIDTH, IMAGE_HEIGHT); printf("Initializing data\n"); vbx_timestamp_start(); for(l = 0; l < 1; l++){ char *src; char *sdst; char *vdst; char *mdst; if(l == 0){ load_lenna(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_lenna(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_lenna(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nLenna\n"); src = "lenna"; sdst = "s_lenna"; vdst = "v_lenna"; mdst = "m_lenna"; }else if(l == 1){ load_ms(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_ms(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_ms(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nMicrosoft\n"); src = "ms"; sdst = "s_ms"; vdst = "v_ms"; mdst = "m_ms"; }else if(l == 2){ load_blank(input, IMAGE_WIDTH, IMAGE_HEIGHT); load_blank(vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT); load_blank(vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT); printf("\nblank\n"); src = "blank"; sdst = "s_blank"; vdst = "v_blank"; mdst = "m_blank"; } #if UNIT int window = 20; int log=0; while(((window/3)>>log) >= 2) log++; errors += compare_scalar_rgb2luma_to_vbw_rgb2luma16(img, vbx_img, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, MAX_PRINT_ERRORS); vbw_rgb2luma8(vbx_img8, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH); int s; #if LUT_CI #if DOUBLE_LUT printf("Testing double lut\n"); printf("Assign lbp double lut\n"); assign_lbp_lut_ci2(); int prev = errors; printf("Cascade check\n"); /* errors += cascade_check_2w(face_lbp, face_lbp_max_stage, 256); */ /* errors += cascade_check_2h(face_lbp, face_lbp_max_stage, 256); */ errors += cascade_check_2b(face_lbp, face_lbp_max_stage, 256); if (errors) { printf("errors %d\n", errors-prev); } #else assign_lbp_lut_ci(); printf("Testing cascade\n"); int prev = errors; printf("lut check\n"); #if 0 #if 0 errors += lut_check(256, 0, 0, 0); if (errors) { printf("errors %d\n", errors-prev); } #elif 1 int print_errors = 0; vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); int vci_lanes = this_mxp->vcustom0_lanes; int num_features = cascade_max_feature(); int input_length = 10; int lut_length = num_features*vci_lanes; int lut_iterations = 15; #if 1 lut_length = input_length = 128; lut_iterations = 13; print_errors = 0; errors += lut_check2(input_length, lut_length, lut_iterations, print_errors); if (errors) { printf("errors %d\n", errors-prev); } #elif 1 input_length = 64; lut_length = input_length; lut_iterations = 13; print_errors = 1; errors += lut_check2(input_length, lut_length, lut_iterations, print_errors); if (errors) { printf("errors %d\n", errors-prev); } #else for(s = 2; s < 100; s=s+10){ errors += lut_check2(s, lut_length, lut_iterations, print_errors); if (errors - prev > 0) { printf("%d\terrors %d\n", s, errors-prev); } else { printf("%d\n", s); } prev = errors; } #endif #else for(s = 0; s < 2000; s=s+100){ errors += lut_check(s, 0, 0, 0); if (errors - prev > 0) { printf("%d\terrors %d\n", s, errors-prev); } else { printf("%d\n", s); } prev = errors; } #endif #elif 1 #else printf("check cascade\n"); prev = errors; errors += cascade_check(face_lbp, face_lbp_max_stage, 256); if (errors) { printf("errors %d\n", errors-prev); } printf("Testing LBP LUT CI\n"); prev = errors; for(s = 0; s < face_lbp_max_stage; s++){ errors += compare_vbx_lut_to_vbx_lut_ci(s, MAX_PRINT_ERRORS); } if (errors) { printf("errors %d\n", errors-prev); prev = errors; } #endif #endif #endif #if 0 printf("Printing grey scale img\n"); printf("grey = ["); for (j = 0; j < IMAGE_HEIGHT; j++) { printf("["); for (i = 0; i < IMAGE_WIDTH; i++) { printf("%d, ", vbx_img8[j*IMAGE_WIDTH+i]); } printf("],\n"); } printf("]\n"); #endif #if LBP_CI printf("Testing LBP Pattern CI\n"); errors += compare_LBPRestrictedCI_to_test_scalar_patterns(vbx_img, vbx_img8, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #endif #if BLIP printf("Testing BLIP\n"); for(s = 1; s < 10; s++){ errors += compare_scalar_BLIP2_to_vector_BLIP(img, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS, s); } #endif #if 0 errors += compare_LBPRestrictedSums_to_test_scalar_sums_byte(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_LBPRestrictedSums2_to_test_scalar_sums_half(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_ScalarLBPRestrictedSums_to_test_scalar_sums_half(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_ScalarLBPRestrictedPatterns_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_LBPRestrictedPatterns2_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_LBPRestricted_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* overflow issues -- using bytes changes lbp pattern */ errors += compare_LBPRestrictedPatterns_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* requires SKIP_INTEGRALS 0 */ errors += compare_gen_integrals_to_vector_get_img(img, iImg, iiImg, vbx_img, vbx_iImg, vbx_iiImg, vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); /* redundant test, compare to test_scalar_patterns instead */ errors += compare_ScalarLBPRestrictedPatterns_to_SATBinaryPattern(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_SATBinaryPattern_to_test_scalar_patterns(vbx_img, log, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); errors += compare_LBPPassStage_to_restricted(vbx_img, log, face_lbp[0], window, IMAGE_WIDTH, IMAGE_HEIGHT, MAX_PRINT_ERRORS); #endif #else // UNIT #if PRINT print_python_pixel(scalar_input, src, IMAGE_WIDTH, IMAGE_HEIGHT); #endif time_start = vbx_timestamp(); scalar_rgb2luma(scalar_short, input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH); scalar_face_detect_luma(scalar_short, input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, sdst); time_stop = vbx_timestamp(); scalar_time = vbx_print_scalar_time(time_start, time_stop); #if PRINT print_python_pixel(scalar_input, sdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif printf("\nVector"); time_start = vbx_timestamp(); vector_face_detect((pixel *)vbx_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, 0, vdst); time_stop = vbx_timestamp(); vbx_time = vbx_print_vector_time(time_start, time_stop, scalar_time); #if PRINT print_python_pixel(vbx_input, vdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif printf("\nVector Masked"); time_start = vbx_timestamp(); vector_face_detect((pixel *)vbx_input_masked, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, 1, mdst); time_stop = vbx_timestamp(); vbx_time_masked = vbx_print_vector_time(time_start, time_stop, scalar_time); #if PRINT print_python_pixel(vbx_input_masked, mdst, IMAGE_WIDTH, IMAGE_HEIGHT); #endif /* errors += match_array_pixel(input, vbx_input, "vector", IMAGE_WIDTH, IMAGE_HEIGHT, 0, MAX_PRINT_ERRORS, 0); */ /* errors += match_array_pixel(input, vbx_input_masked, "masked", IMAGE_WIDTH, IMAGE_HEIGHT, 0, MAX_PRINT_ERRORS, 0); */ errors += match_array_pixel(vbx_input, vbx_input_masked, "masked", IMAGE_WIDTH, IMAGE_HEIGHT, 0, MAX_PRINT_ERRORS, 0); #endif // UNIT } VBX_TEST_END(errors); return errors; }
int main(void) { pixel *input; pixel *scalar_input; #if USE_LUMA unsigned char *vbx_luma; #endif unsigned short *scalar_luma; pixel *vbx_output; pixel *scalar_output; vbx_timestamp_t time_start, time_stop; double scalar_time, vbx_time; int x, y; int errors = 0; vbx_test_init(); vbx_mxp_print_params(); input = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_input = (pixel *)vbx_remap_cached(input, IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); #if USE_LUMA vbx_luma = (unsigned char *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned char)); #endif scalar_luma = (unsigned short *)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(unsigned short)); vbx_output = (pixel *)vbx_shared_malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); scalar_output = (pixel *)malloc(IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(pixel)); printf("\nInitializing data\n"); printf("Resolution = %dx%d\n", IMAGE_WIDTH, IMAGE_HEIGHT); init_matrix(input, IMAGE_WIDTH, IMAGE_HEIGHT); printf("Starting Sobel 3x3 edge-detection test\n"); #if USE_LUMA scalar_rgb2luma(scalar_luma, scalar_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH); #endif vbx_timestamp_start(); time_start = vbx_timestamp(); #if !USE_LUMA scalar_rgb2luma(scalar_luma, scalar_input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH); #endif scalar_sobel_argb32_3x3(scalar_output, scalar_luma, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH, RENORM_AMOUNT); time_stop = vbx_timestamp(); scalar_time = vbx_print_scalar_time(time_start, time_stop); #if USE_LUMA vbw_rgb2luma8(vbx_luma, (unsigned *)input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH); #endif vbx_timestamp_start(); time_start = vbx_timestamp(); #if USE_LUMA vbw_sobel_luma8_3x3((unsigned *)vbx_output, vbx_luma, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH, RENORM_AMOUNT); #else vbw_sobel_argb32_3x3((unsigned *)vbx_output, (unsigned *)input, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PITCH, RENORM_AMOUNT); #endif time_stop = vbx_timestamp(); vbx_time = vbx_print_vector_time(time_start, time_stop, scalar_time); for (y = 0; y < IMAGE_HEIGHT; y++) { for (x = 0; x < IMAGE_WIDTH; x++) { #if USE_LUMA if (scalar_luma[y*IMAGE_WIDTH+x] != vbx_luma[y*IMAGE_WIDTH+x]) { if (errors < MAX_PRINT_ERRORS) { printf("Y Error at %d, %d: Expected = %02X, got = %02X\n", y, x, scalar_luma[y*IMAGE_WIDTH+x], vbx_luma[y*IMAGE_WIDTH+x]); } errors++; } #endif if (scalar_output[y*IMAGE_WIDTH+x].r != vbx_output[y*IMAGE_WIDTH+x].r) { if (errors < MAX_PRINT_ERRORS) { printf("R Error at %d, %d: Expected = %02X, got = %02X\n", y, x, scalar_output[y*IMAGE_WIDTH+x].r, vbx_output[y*IMAGE_WIDTH+x].r); } errors++; } if (scalar_output[y*IMAGE_WIDTH+x].g != vbx_output[y*IMAGE_WIDTH+x].g) { if (errors < MAX_PRINT_ERRORS) { printf("G Error at %d, %d: Expected = %02X, got = %02X\n", y, x, scalar_output[y*IMAGE_WIDTH+x].g, vbx_output[y*IMAGE_WIDTH+x].g); } errors++; } if (scalar_output[y*IMAGE_WIDTH+x].b != vbx_output[y*IMAGE_WIDTH+x].b) { if (errors < MAX_PRINT_ERRORS) { printf("B Error at %d, %d: Expected = %02X, got = %02X\n", y, x, scalar_output[y*IMAGE_WIDTH+x].b, vbx_output[y*IMAGE_WIDTH+x].b); } errors++; } } } VBX_TEST_END(errors); return errors; }