Пример #1
0
Файл: test.c Проект: 8l/mxp
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;
}
Пример #2
0
Файл: test.c Проект: 8l/mxp
int deep_vector_copy_test()
{
	int retval;
	int num_test;
	int total_errors = 0;
	const int NUM_TESTS = TEST_DEEP_SP_NUM_TESTS;
	const int NB = vbx_sp_getfree();

	int NT = NB / sizeof(vbx_sp_t);

	vbx_sp_push();
	vbx_sp_t *v = vbx_sp_malloc( NB );

	srand( 0x1a84c92a );

	for( num_test=0; num_test < NUM_TESTS ; num_test++ ) {

		// initialize entire available scratchpad
		vbx_set_vl( NT );
		vbx( SE(T), VAND, v, MSK, 0 );

		// choose random src/dest/length:
		// -- randomly pick the dest
		// -- set a window size of 2*K around the dest
		// -- randomly pick the src within the window
		// -- randomly pick the length, subject to end-of-scratchpad
		// -- this 'window' rule increases probability of overlaps
		// -- rough distribution: 30% short (pipeline) overlaps, 20% long overlaps, 50% no overlap

		int K, N1, N2, NN;
		N1 = rand() % NT;
		K  = 1 + rand() % ((N1 > 0)? min(min(N1, NT-N1), 1024): min(NT, 1024));
		N2 = N1 - K + rand() % (2*K);
		NN = rand() % (NT - max(N1,N2));
		vbx_sp_t *dst = v + N1;
		vbx_sp_t *src = v + N2;

		printf("test:%d src:0x%08x dst:0x%08x len:%08d", num_test, N1, N2, NN );

		// do the copy
		retval = VBX_T(vbw_vec_copy)( dst, src, NN );
		vbx_sync();
		printf(" retval:0x%04x\n",retval);

		// ensure the copy was done properly
		int errors = verify_copy((vbx_mm_t *)v,     0,    N1,       0, "head")
		           + verify_copy((vbx_mm_t *)v,    N1, NN+N1, (N2-N1), "copy")
		           + verify_copy((vbx_mm_t *)v, NN+N1,    NT,       0, "tail");
		total_errors += errors;
		if( errors ) {
			//break;
		}
	}

	vbx_sp_pop();
	return total_errors;
}
Пример #3
0
Файл: test.c Проект: 8l/mxp
int deep_vector_copy_ext_test()
{
	vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP();
	int retval;
	int num_test;
	int total_errors = 0;
	const int NUM_TESTS = TEST_DEEP_MM_NUM_TESTS;
	int NB = this_mxp->scratchpad_size * 10;
	int NT = NB / sizeof(vbx_mm_t);

	vbx_mm_t *v = vbx_shared_malloc( NB );

	srand( 0x1a84c92a );

	int i;

	for( num_test=0; num_test < NUM_TESTS ; num_test++ ) {

		//	initialize the whole working space
		for( i=0; i<NT; i++ ) {
			v[i] = i & MSK;
		}

		// choose random src/dest/length:
		// -- randomly pick the dest
		// -- set a window size of 2*K around the dest
		// -- randomly pick the src within the window
		// -- randomly pick the length, subject to end-of-scratchpad
		// -- this 'window' rule increases probability of overlaps
		// -- rough distribution: 30% short (pipeline) overlaps, 20% long overlaps, 50% no overlap

		int K, N1, N2, NN;
		N1 = rand() % NT;
		K  = 1 + rand() % ((N1 > 0)? min(min(N1, NT-N1), 1024): min(NT, 1024));
		N2 = N1 - K + rand() % (2*K);
		NN = rand() % (NT - max(N1,N2));
		vbx_mm_t *dst = v + N1;
		vbx_mm_t *src = v + N2;
		printf("test:%d src:0x%08x dst:0x%08x len:%08d", num_test, N1, N2, NN );

		// do the copy
		retval = VBX_T(vbw_vec_copy_ext)( dst, src, NN );
		vbx_sync();
		printf(" retval:0x%04x\n",retval);

		// ensure the copy was done properly
		int errors = verify_copy(v,     0,    N1,       0, "head")
		           + verify_copy(v,    N1, NN+N1, (N2-N1), "copy")
		           + verify_copy(v, NN+N1,    NT,       0, "tail");
		total_errors += errors;
		if( errors ) {
			//break;
		}
	}

	return total_errors;
}
Пример #4
0
Файл: test.c Проект: 8l/mxp
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 );
}
Пример #5
0
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 );
}
Пример #6
0
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 );
}
Пример #7
0
Файл: test.c Проект: 8l/mxp
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 );
}
Пример #8
0
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 );
}
Пример #9
0
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 );
}
Пример #10
0
Файл: test.c Проект: 8l/mxp
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);
}
Пример #11
0
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 );
}
Пример #12
0
Файл: test.c Проект: 8l/mxp
int VBX_T(vbw_vec_reverse_test)()
{
	unsigned int aN[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 20, 25, 31, 32, 33, 35, 40, 48, 60, 61, 62, 63, 64, 64, 65,
	                      66, 67, 68, 70, 80, 90, 99, 100, 101, 110, 128, 128, 144, 144, 160, 160, 176, 176, 192, 192, 224, 224,
	                      256, 256, 288, 288, 320, 320, 352, 352, 384, 384, 400, 450, 512, 550, 600, 650, 700, 768, 768, 900,
	                      900, 1023, 1024, 1200, 1400, 1600, 1800, 2048, 2048, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800,
	                      2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4096, 4096, 4100, 4200, 4300,
	                      4400, 4500, 4600, 4700, 4800, 4900, 5000, 6000, 7000, 8000, 8192, 8192, 9000, 10000, 11000, 12000,
	                      13000, 14000, 15000, 16000, 16384, 16384, 20000, 25000, 30000, 32767, 32768, 32768, 35000, 40000,
	                      45000, 50000, 55000, 60000, 65000, 65535, 65536, 65536 };

	int retval;
	unsigned int N;
	unsigned int NBYTES;
	unsigned int NREPS = 100;
	unsigned int i,k;

	vbx_timestamp_t start=0,finish=0;

	vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP();
	const unsigned int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size;

	for( i=0; i<sizeof(aN)/4; i++ ) {
		N = aN[i];
		//printf( "testing with vector size %d\n", N );

		NBYTES = sizeof(vbx_sp_t)*N;
		if( 2*NBYTES > VBX_SCRATCHPAD_SIZE ) continue;

		vbx_sp_t *vsrc = vbx_sp_malloc( NBYTES );
		vbx_sp_t *vdst = vbx_sp_malloc( NBYTES );
		//printf("bytes alloc: %d\n", NBYTES );

		if( !vsrc ) VBX_EXIT(-1);
		if( !vdst ) VBX_EXIT(-1);

		#if   ( VBX_TEMPLATE_T == BYTESIZE_DEF | VBX_TEMPLATE_T == UBYTESIZE_DEF )
			unsigned int mask = 0x007F;
		#elif ( VBX_TEMPLATE_T == HALFSIZE_DEF | VBX_TEMPLATE_T == UHALFSIZE_DEF )
			unsigned int mask = 0x7FFF;
		#else
			unsigned int mask = 0xFFFF;
		#endif

		vbx_set_vl( N );
		vbx( SV(T), VMOV, vdst,   -1, 0 );       // Fill the destination vector with -1
		vbx( SE(T), VAND, vsrc, mask, 0 );       // Fill the source vector with enumerated values
		//VBX_T(print_vector)( "vsrcInit", vsrc, N );
		//VBX_T(print_vector)( "vdstInit", vdst, N );

		/** measure performance of function call **/
		vbx_sync();
		start = vbx_timestamp();
		for(k=0; k<NREPS; k++ ) {
			retval = VBX_T(vbw_vec_reverse)( vdst, vsrc, N );
			vbx_sync();
		}
		finish = vbx_timestamp();
		printf( "length %d (%s):\tvbware sp f():\t%llu", N, VBX_EXPAND_AND_QUOTE(BYTEHALFWORD), (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) );
		//VBX_T(print_vector)( "vsrcPost", vsrc, N );
		//VBX_T(print_vector)( "vdstPost", vdst, N );

		#if VERIFY_VBWARE_ALGORITHM
			VBX_T(verify_vector)( vsrc, vdst, N );
		#else
			printf(" [VERIFY OFF]");
		#endif

		printf("\treturn value: %X", retval);

		vbx_set_vl( N );
		vbx( SE(T), VAND, vsrc, mask, 0 );       // Reset the source vector

		/** measure performance of simple algorithm **/
		vbx_sync();
		vbx_set_vl( 1 );
		vbx_set_2D( N, -sizeof(vbx_sp_t), sizeof(vbx_sp_t), 0 );

		start = vbx_timestamp();
		for(k=0; k<NREPS; k++ ) {
			vbx_2D( VV(T), VMOV, vdst+N-1, vsrc, 0 );
			vbx_sync();
		}
		finish = vbx_timestamp();

		printf( "\tsimple (vl=1):\t%llu", (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) );

		#if VERIFY_SIMPLE_ALGORITHM
			VBX_T(verify_vector)( vsrc, vdst, N );
		#else
			printf(" [VERIFY OFF]");
		#endif
			printf("\tcycles\n");

		vbx_sp_free();
	}

	vbx_sp_free();
	printf("All tests passed successfully.\n");

	return 0;
}
Пример #13
0
Файл: test.c Проект: 8l/mxp
int VBX_T(vbw_vec_reverse_test_mm)()
{
	unsigned int aN[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 20, 25, 31, 32, 33, 35, 40, 48, 60, 61, 62, 63, 64, 64, 65,
	                      66, 67, 68, 70, 80, 90, 99, 100, 101, 110, 128, 128, 144, 144, 160, 160, 176, 176, 192, 192, 224, 224,
	                      256, 256, 288, 288, 320, 320, 352, 352, 384, 384, 400, 450, 512, 550, 600, 650, 700, 768, 768, 900,
	                      900, 1023, 1024, 1200, 1400, 1600, 1800, 2048, 2048, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800,
	                      2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4096, 4096, 4100, 4200, 4300,
	                      4400, 4500, 4600, 4700, 4800, 4900, 5000, 6000, 7000, 8000, 8192, 8192, 9000, 10000, 11000, 12000,
	                      13000, 14000, 15000, 16000, 16384, 16384, 20000, 25000, 30000, 32767, 32768, 32768, 35000, 40000,
	                      45000, 50000, 55000, 60000, 65000, 65535, 65536, 65536, 65537, 100000, 128000, 256000, 333333, 528374,
	                      528374 };

	int retval;
	unsigned int N;
	unsigned int NBYTES;
	unsigned int NREPS = 100;
	unsigned int NREPSFORLARGE = 10;
	unsigned int i,j,k;
	vbx_timestamp_t start=0,finish=0;

	for( i=0; i<sizeof(aN)/4; i++ ) {
		N = aN[i];
		//printf( "testing with vector size %d\n", N );

		if(N > 10000) NREPS = NREPSFORLARGE;

		NBYTES = N*sizeof(vbx_mm_t);

		vbx_mm_t *src = (vbx_mm_t *) vbx_shared_malloc( NBYTES );
		vbx_mm_t *dst = (vbx_mm_t *) vbx_shared_malloc( NBYTES );
		//printf("bytes alloc: %d\n", NBYTES );

		if( !src ) VBX_EXIT(-1);
		if( !dst ) VBX_EXIT(-1);

		for ( j=0; j<N; j++ ) {
			dst[j] = -1;                 // Fill the destination with -1
			src[j] = j;                  // Fill the source with enumerated values
		}

//			VBX_T(vbw_vec_reverse_ext)( dst, src, N );

		/** measure performance of function call **/
		start = vbx_timestamp();
		for(k=0; __builtin_expect(k<NREPS,1); k++ ) {
			retval = VBX_T(vbw_vec_reverse_ext)( dst, src, N );
		}
		finish = vbx_timestamp();
		printf( "length %d (%s):\tvbware mm f():\t%llu", N, VBX_EXPAND_AND_QUOTE(BYTEHALFWORD), (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) );

		#if VERIFY_VBWARE_ALGORITHM
			VBX_T(verify_vector)( src, dst, N );
		#else
			printf(" [VERIFY OFF]");
		#endif

		printf("\treturn value: %X", retval);

		/** measure performance of scalar **/
		vbx_mm_t *A = vbx_remap_cached( src, N*sizeof(vbx_mm_t) );   // Use cached pointers for better performance
		vbx_mm_t *B = vbx_remap_cached( dst, N*sizeof(vbx_mm_t) );
		start = vbx_timestamp();
		for(k=0; k<NREPS; k++ ) {
			unsigned int m;
			for(m=0; m<N; m++) {
				B[N-1-m]=A[m];
			}
		vbx_dcache_flush( A, N*sizeof(vbx_mm_t) );               // Make sure to read from main memory
		vbx_dcache_flush( B, N*sizeof(vbx_mm_t) );               // Make sure writes are committed to memory
		}
		finish = vbx_timestamp();

		printf( "\tscalar (cache friendly):\t%llu", (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) );

		#if VERIFY_SIMPLE_ALGORITHM
			VBX_T(verify_vector)( src, dst, N );
		#else
			printf(" [VERIFY OFF]");
		#endif
			printf("\tcycles\n");

			vbx_shared_free(src);
			vbx_shared_free(dst);
	}

	printf("All tests passed successfully.\n");

	return 0;
}
Пример #14
0
int main(void)
{
	double scalar_time, vector_time;
	int errors=0;

	vbx_test_init();

	vbx_mxp_print_params();
	printf("\nVector FIR test...\n");

	vbx_mm_t *scalar_sample = malloc( (SAMP_SIZE+NTAPS)*sizeof(vbx_mm_t) );
	vbx_mm_t *scalar_coeffs = malloc(             NTAPS*sizeof(vbx_mm_t) );
	vbx_mm_t *scalar_out    = malloc(         SAMP_SIZE*sizeof(vbx_mm_t) );

	vbx_mm_t *sample     = vbx_shared_malloc( (SAMP_SIZE+NTAPS)*sizeof(vbx_mm_t) );
	vbx_mm_t *coeffs     = vbx_shared_malloc(             NTAPS*sizeof(vbx_mm_t) );
	vbx_mm_t *vector_out = vbx_shared_malloc(         SAMP_SIZE*sizeof(vbx_mm_t) );

	VBX_T(test_zero_array)( scalar_out, SAMP_SIZE );
	VBX_T(test_zero_array)( vector_out, SAMP_SIZE );

	VBX_T(test_init_array)( scalar_sample, SAMP_SIZE, 0xff );
	VBX_T(test_copy_array)( sample, scalar_sample, SAMP_SIZE );
	VBX_T(test_init_array)( scalar_coeffs, NTAPS, 1 );
	VBX_T(test_copy_array)( coeffs, scalar_coeffs, NTAPS );

	VBX_T(test_zero_array)( scalar_sample+SAMP_SIZE, NTAPS );
	VBX_T(test_zero_array)( sample+SAMP_SIZE, NTAPS );

	printf("\nSamples:\n");
	VBX_T(test_print_array)( scalar_sample, min(SAMP_SIZE,MAX_PRINT_LENGTH) );
	printf("\nCoefficients:\n");
	VBX_T(test_print_array)( scalar_coeffs, min(NTAPS,MAX_PRINT_LENGTH) );

	scalar_time = test_scalar( scalar_out, scalar_sample, scalar_coeffs);
	VBX_T(test_print_array)( scalar_out,  min(SAMP_SIZE,MAX_PRINT_LENGTH) );

	#ifdef USE_TRANSPOSE
	vector_time = test_vector_transpose( vector_out, sample, coeffs, scalar_time );
	VBX_T(test_print_array)( vector_out,  min(SAMP_SIZE,MAX_PRINT_LENGTH) );
	errors += VBX_T(test_verify_array)( scalar_out, vector_out, SAMP_SIZE-NTAPS );
	#endif //USE_TRANSPOSE

	#ifdef USE_1D
	vector_time = test_vector_1d( vector_out, sample, coeffs, scalar_time );
	VBX_T(test_print_array)( vector_out,  min(SAMP_SIZE,MAX_PRINT_LENGTH) );
	errors += VBX_T(test_verify_array)( scalar_out, vector_out, SAMP_SIZE-NTAPS );
	#endif //USE_1D

	#ifdef USE_2D
	vector_time = test_vector_2d( vector_out, sample, coeffs, scalar_time );
	VBX_T(test_print_array)( vector_out,  min(SAMP_SIZE,MAX_PRINT_LENGTH) );
	errors += VBX_T(test_verify_array)( scalar_out, vector_out, SAMP_SIZE-NTAPS );
	#endif //USE_2D

	VBX_TEST_END(errors);
	return 0;
}
Пример #15
0
Файл: test.c Проект: 8l/mxp
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;
}
Пример #16
0
int main(void)
{
	vbx_test_init();

	vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP();
	const int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size;
	const int required_vectors = 4;

	int N = VBX_SCRATCHPAD_SIZE / sizeof(vbx_mm_t) / required_vectors;

	int PRINT_LENGTH = min( N, MAX_PRINT_LENGTH );

	double scalar_time, vector_time;
	int errors=0;

	vbx_mxp_print_params();
	printf( "\nAdd test...\n" );
	printf( "Vector length: %d\n", N );

	vbx_mm_t *scalar_in1 = malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *scalar_in2 = malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *scalar_out = malloc( N*sizeof(vbx_mm_t) );

	vbx_mm_t *vector_in1 = vbx_shared_malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *vector_in2 = vbx_shared_malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *vector_out = vbx_shared_malloc( N*sizeof(vbx_mm_t) );
//	vbx_mm_t *vector_out = vector_in2 - 5;


	vbx_sp_t *v_in1 = vbx_sp_malloc( N*sizeof(vbx_sp_t) );
	vbx_sp_t *v_in2 = vbx_sp_malloc( N*sizeof(vbx_sp_t) );
	vbx_sp_t *v_out = vbx_sp_malloc( N*sizeof(vbx_sp_t) );
//	vbx_sp_t *v_out = v_in2-5;

	VBX_T(test_zero_array)( scalar_out, N );
	VBX_T(test_zero_array)( vector_out, N );

	VBX_T(test_init_array)( scalar_in1, N, 1 );
	VBX_T(test_copy_array)( vector_in1, scalar_in1, N );
	VBX_T(test_init_array)( scalar_in2, N, 1 );
	VBX_T(test_copy_array)( vector_in2, scalar_in2, N );

	VBX_T(test_print_array)( scalar_in1, PRINT_LENGTH );
	VBX_T(test_print_array)( scalar_in2, PRINT_LENGTH );

	scalar_time = test_scalar( scalar_out, scalar_in1, scalar_in2, N );
	VBX_T(test_print_array)( scalar_out, PRINT_LENGTH);

	vbx_dma_to_vector( v_in1, (void *)vector_in1, N*sizeof(vbx_sp_t) );
	vbx_dma_to_vector( v_in2, (void *)vector_in1, N*sizeof(vbx_sp_t) );
	vector_time = test_vector( v_out, v_in1, v_in2, N, scalar_time );
	vbx_dma_to_host( (void *)vector_out, v_out, N*sizeof(vbx_sp_t) );
	vbx_sync();
	VBX_T(test_print_array)( vector_out, PRINT_LENGTH );

	errors += VBX_T(test_verify_array)( scalar_out, vector_out, N );

	VBX_TEST_END(errors);
	return 0;
}
Пример #17
0
Файл: test.c Проект: 8l/mxp
int main(void)
{
	vbx_test_init();

	vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP();
	const int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size;
	const int required_vectors = 4;

	int N = VBX_PAD_DN(VBX_SCRATCHPAD_SIZE / sizeof(vbx_mm_t) / required_vectors, this_mxp->scratchpad_alignment_bytes);

	int PRINT_LENGTH = min( N, MAX_PRINT_LENGTH );

	double scalar_time, vector_time;
	int errors=0;

	vbx_mxp_print_params();
	printf( "\nVector copy test...\n" );
	printf( "Vector length: %d\n", N );

	vbx_mm_t *scalar_in  = malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *scalar_out = malloc( N*sizeof(vbx_mm_t) );

	vbx_mm_t *vector_in  = vbx_shared_malloc( N*sizeof(vbx_mm_t) );
	vbx_mm_t *vector_out = vbx_shared_malloc( N*sizeof(vbx_mm_t) );

	vbx_sp_t *v_out = vbx_sp_malloc( N*sizeof(vbx_sp_t) );
	vbx_sp_t *v_in = vbx_sp_malloc( N*sizeof(vbx_sp_t) );

	VBX_T(test_zero_array)( scalar_in, N );
	VBX_T(test_zero_array)( vector_in, N );

	VBX_T(test_init_array)( scalar_in, N, 1 );
	VBX_T(test_copy_array)( vector_in, scalar_in, N );

	scalar_time = test_scalar( scalar_out, scalar_in, N );
	VBX_T(test_print_array)( scalar_out, PRINT_LENGTH );

	vbx_dma_to_vector( v_in, vector_in, N*sizeof(vbx_sp_t) );
	vector_time = test_vector( v_out, v_in, N, scalar_time );
	vbx_dma_to_host(vector_out, v_out, N*sizeof(vbx_sp_t) );
	vbx_sync();
	VBX_T(test_print_array)( vector_out, PRINT_LENGTH );

	errors += VBX_T(test_verify_array)( scalar_out, vector_out, N );

	vbx_sp_free();

#if TEST_DEEP_SP
	errors += deep_vector_copy_test();
#endif

#if DEBUG_MAKE_SP_FULL
	vbx_sp_malloc(vbx_sp_getfree());
#endif

#if TEST_DEEP_MM
	errors += deep_vector_copy_ext_test();
#endif

	VBX_TEST_END(errors);

	return 0;
}