コード例 #1
0
ファイル: testbench.c プロジェクト: madhavPdesai/ahir
int main(int argc, char* argv[])
{
	float result[ORDER];
	signal(SIGINT,  Exit);
  	signal(SIGTERM, Exit);

#ifdef SW
#ifdef USE_GNUPTH
	pth_init();
#endif
	init_pipe_handler();
	PTHREAD_DECL(conversionTest);
	PTHREAD_CREATE(conversionTest);
#endif
	PTHREAD_DECL(Sender);
	PTHREAD_CREATE(Sender);

	uint8_t idx;
	


	read_uint64_n("out_data",((uint64_t*) result),ORDER/2);

	for(idx = 0; idx < ORDER; idx++)
	{
		fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expected_result[idx]);
	}
	PTHREAD_CANCEL(Sender);
#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(conversionTest);
#endif
	return(0);
}
コード例 #2
0
int main(int argc, char* argv[])
{
    uint32_t result[ORDER];
    signal(SIGINT,  Exit);
    signal(SIGTERM, Exit);

#ifdef SW
    init_pipe_handler_with_log("pipeHandler.log");
    _start_daemons(stderr);
#endif
    PTHREAD_DECL_AND_CREATE(Sender);

    read_uint32_n("out_data",result,ORDER);

    uint32_t idx;
    for(idx = 0; idx < ORDER; idx++)
    {
        fprintf(stdout,"Result = %u, expected = %u.\n", result[idx],idx+1);
    }
    PTHREAD_CANCEL(Sender);
#ifdef SW
    close_pipe_handler();
    _stop_daemons();
#endif
    return(0);
}
コード例 #3
0
ファイル: testbench.c プロジェクト: madhavPdesai/ahir
int main(int argc, char* argv[])
{
    float result;
    signal(SIGINT,  Exit);
    signal(SIGTERM, Exit);

#ifdef SW
    init_pipe_handler();
    PTHREAD_DECL(dotProduct);
    PTHREAD_CREATE(dotProduct);
#endif

    uint8_t idx;
    float expected_result = 0.0;
    for(idx = 0; idx < ORDER; idx++)
    {
        float val = drand48();
        expected_result += (val*val);
        write_float32("in_data_pipe",val);
    }


    result = read_float32("out_data_pipe");
    fprintf(stdout,"Result = %f, expected = %f.\n", result, expected_result);
#ifdef SW
    close_pipe_handler();
    PTHREAD_CANCEL(dotProduct);
    return(0);
#endif
}
コード例 #4
0
ファイル: simple_check.c プロジェクト: arunkumarcea/ahir
// shows the use of the pipeHandler.
int main(int argc, char* argv[])
{
	// must be initialized before doing anything
        init_pipe_handler();

	// register a FIFO pipe test_pipe with
	// depth 32, word-width 32.
	register_pipe("test_pipe",32,32,0);
	register_pipe("test_pipe_64",1,64,0);

	// write a integer to test_pipe.
	write_uint32("test_pipe",1);
	uint64_t tmp = 1;
	tmp = tmp | (tmp << 32);
	write_uint64("test_pipe_64",tmp);

	// read back and print integer.
	uint32_t v = read_uint32("test_pipe");
	fprintf(stderr,"TEST: received uint32_t %d\n", v);

	uint64_t v64 = read_uint64("test_pipe_64");
	fprintf(stderr,"TEST: received uint64_t %llu\n", v64);

	// write another integer
	write_uint32("test_pipe",1);

	// read back and print integer.
	v = read_uint32("test_pipe");
	fprintf(stderr,"TEST: received %d\n", v);

	// close the handler.
        close_pipe_handler();
        return(0);
}
コード例 #5
0
ファイル: testbench.c プロジェクト: arunkumarcea/ahir
int main(int argc, char* argv[])
{
	signal(SIGINT,  Exit);
  	signal(SIGTERM, Exit);

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(vectorSum);
	PTHREAD_CREATE(vectorSum);
#endif


	write_uint32("in_data",1);
	write_uint32("in_data",2);
	write_uint32("in_data",3);
	write_uint32("in_data",4);

	uint32_t rval = read_uint32("out_data");
	fprintf(stdout,"Result = %d.\n", rval);

#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(vectorSum);
#endif
	return(0);
}
コード例 #6
0
ファイル: testbenc1h.c プロジェクト: arunkumarcea/ahir
int main(int argc, char* argv[])
{
#ifdef SW
	init_pipe_handler_with_log("pipelog.txt");
	PTHREAD_DECL(maxDaemon);   // declare the Daemon thread.
	PTHREAD_CREATE(maxDaemon); // start the Daemon..
#endif
	while(1)
	{
		uint32_t a, b;
		scanf("%d", &a);
		scanf("%d", &b);
		write_uint32("in_data",a);
		write_uint32("in_data",b);
		uint32_t c = read_uint32("out_data");
		fprintf(stdout,"Result = %d.\n", c);

		if(a == 0)
			break;
	}

#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(maxDaemon);
#endif
	return(0);
}
コード例 #7
0
ファイル: testbench.c プロジェクト: arunkumarcea/ahir
int main(int argc, char* argv[])
{
	float result[ORDER];
	signal(SIGINT,  Exit);
  	signal(SIGTERM, Exit);

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(vectorSum);
	PTHREAD_CREATE(vectorSum);
#endif
	PTHREAD_DECL(Sender);
	PTHREAD_CREATE(Sender);

	uint8_t idx;
	


	read_float32_n("out_data_pipe",result,ORDER);

	for(idx = 0; idx < ORDER; idx++)
	{
		fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expected_result[idx]);
	}
	PTHREAD_CANCEL(Sender);
#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(vectorSum);
#endif
	return(0);
}
コード例 #8
0
ファイル: test_gcd.c プロジェクト: madhavPdesai/ahir
int main(int argc, char* argv[])
{
        FILE* ofile1;
        FILE* ofile2;
        char ostr[17];
	uint16_t N[ORDER];

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(gcd_daemon);
	PTHREAD_CREATE(gcd_daemon);
#endif

        ofile1 = fopen("gcd_inputs.txt","w");
        ofile2 = fopen("gcd_result.txt","w");

	int err = 0;
   
	uint16_t S = 1;
	if(argc > 1)
		S = atoi(argv[1]);
	fprintf(stderr,"Scale-factor = %d.\n",S);


	srand48(19);

	uint16_t i;
	for(i = 0; i < ORDER; i++)
	{
		N[i] = ((uint16_t) (0x0fff * drand48())) * S;
		fprintf(stderr,"N[%d] = %d\n", i, N[i]);
		write_uint16("in_data",N[i]);
		to_string(ostr,N[i]);
		fprintf(ofile1,"%s\n", ostr);
	}

	uint16_t g = read_uint16("out_data");
	fprintf(stderr,"GCD = %d.\n",g);
	to_string(ostr,g);
	fprintf(ofile2,"%s\n",ostr);

	uint32_t et = read_uint32("elapsed_time");
	fprintf(stderr,"Elapsed time = %u.\n", et);

	fclose(ofile1);
	fclose(ofile2);

#ifdef SW
	PTHREAD_CANCEL(gcd_daemon);
	close_pipe_handler();
#endif

	return(0);
}
コード例 #9
0
int main(int argc, char* argv[])
{
#ifdef SW
	init_pipe_handler_with_log("pipelog.txt");
	PTHREAD_DECL(vector_control_daemon);   // declare the Daemon thread.
	PTHREAD_CREATE(vector_control_daemon); // start the Daemon..
#endif

	double	*iq, 
		*iq_prev,
		*id,
		*id_prev,
		*flq,
		*flq_prev,
		*fld,
		*fld_prev,
		*spd,
		*spd_prev,
		vd,
		vq,
		torque,
		load_torque,
		*time = 0;
	
	double speed_ref
		
	int i=0;
	int no_of_cycles = 4000 ; // 100u/25n (Ideal time necessary for conputation for FPGA/Motor_iteration_step)
				
	while(1)
	{
		for(i = 0; i< no_of_cycles; i++){
			im_zep(&iq,&iq_prev,&id,&id_prev,&flq,&flq_prev,&fld,&fld_prev,&spd_prev,vd,vq,&torque,load_torque,&time)
		}
		
		write_float32("in_data",*id);
		write_float32("in_data",*iq);
		write_float32("in_data",speed_ref);

		vd = read_float32("out_data");
		vq = read_float32("out_data");
	}

#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(vector_control_daemon);
#endif
	return(0);
}
コード例 #10
0
ファイル: testBestFit.c プロジェクト: kartiklakhotia/ecg
int main(int argc, char* argv[])
{
	float result;
	int I, J;

	if(argc < 2)
	{
		fprintf(stderr,"Supply data set file.\n");
		return(1);
	}


	signal(SIGINT,  Exit);
	signal(SIGTERM, Exit);

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(bestFit);
	PTHREAD_DECL(qrsDet);
	PTHREAD_CREATE(bestFit);
	PTHREAD_CREATE(qrsDet);
#endif
	PTHREAD_DECL(Sender);
	PTHREAD_DECL(Receiver);	
	PTHREAD_CREATE_WITH_ARG(Sender, argv[1]);
	PTHREAD_CREATE(Receiver);

	PTHREAD_JOIN(Sender);
	PTHREAD_CANCEL(Receiver);
	



#ifdef SW
	PTHREAD_CANCEL(qrsDet);
	PTHREAD_CANCEL(bestFit);
	close_pipe_handler();
	return(0);
#endif
}
コード例 #11
0
ファイル: testbench.c プロジェクト: madhavPdesai/ahir
int main(int argc, char* argv[])
{
	float result[ORDER];
	signal(SIGINT,  Exit);
	signal(SIGTERM, Exit);

	uint8_t idx;
	for(idx = 0; idx < ORDER; idx++)
	{
		op[idx] = idx % 4;
		x[idx] = drand48();
		y[idx] = drand48();
	}
#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(streamProcessor);
	PTHREAD_CREATE(streamProcessor);
#endif
	PTHREAD_DECL(sendX);
	PTHREAD_CREATE(sendX);
	PTHREAD_DECL(sendY);
	PTHREAD_CREATE(sendY);
	PTHREAD_DECL(sendOp);
	PTHREAD_CREATE(sendOp);



	read_float32_n("z_pipe",result,ORDER);

	for(idx = 0; idx < ORDER; idx++)
	{
		fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expectedResult(op[idx], x[idx], y[idx]));
	}
#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(streamProcessor);
#endif
	return(0);
}
コード例 #12
0
ファイル: testbench.c プロジェクト: arunkumarcea/ahir
int main(void)
{
    BYTE init[16] = {
	0, 1, 2, 3,
	4, 5, 6, 7,
	8, 9, 10, 11,
	12, 13, 14, 15
    };

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(Daemon);
	PTHREAD_CREATE(Daemon);
#endif

    sendConstants();

    int i, run;
    long long t1[10], t2[10];

    for (run = 0; run < 10; run++) {
	fprintf(stderr," run %d.\n", run);
	for (i = 0; i < 16; i++) {
	    write_uint8("input_block_pipe", init[i]);
	    fprintf(stderr," wrote %x \n", init[i]);
	}

	for (i = 0; i < 16; i++) {
		uint8_t rV = read_uint8("output_block_pipe");
		fprintf(stderr," read-back %x \n", rV);
	}
    }

#ifdef SW
	close_pipe_handler();
	PTHREAD_CANCEL(Daemon);
#endif
    return 0;
}
コード例 #13
0
ファイル: testbench.c プロジェクト: arunkumarcea/ahir
int main(int argc, char* argv[])
{
	signal(SIGINT,  Exit);
  	signal(SIGTERM, Exit);
  	signal(SIGSEGV, Exit);

        int i,j,k;

        srand48(100);

        for(i = 0; i < ORDER; i++)
	{
        	for(j = 0; j < ORDER; j++)
		{
			a_matrix[i][j] = drand48();
			b_matrix[i][j] = drand48();
		}
	}

        for(i = 0; i < ORDER; i++)
	{
        	for(j = 0; j < ORDER; j++)
		{
			expected_c_matrix[i][j] = 0;
        		for(k = 0; k < ORDER; k++)
				expected_c_matrix[i][j] += a_matrix[i][k] * b_matrix[k][j];
		}
	}
	
#ifdef SW
	init_pipe_handler();

	PTHREAD_DECL(mmultiply);
	PTHREAD_DECL(mmultiply_LL);
	PTHREAD_DECL(mmultiply_LH);
	PTHREAD_DECL(mmultiply_HH);
	PTHREAD_DECL(mmultiply_HL);

	PTHREAD_CREATE(mmultiply);
	PTHREAD_CREATE(mmultiply_LL);
	PTHREAD_CREATE(mmultiply_LH);
	PTHREAD_CREATE(mmultiply_HH);
	PTHREAD_CREATE(mmultiply_HL);
#endif

	write_matrices();
	read_result_matrix();



	fprintf(stdout,"results: \n ");
	for(i = 0; i < ORDER; i++)
	{
		for(j = 0; j < ORDER; j++)
		{
			if(expected_c_matrix[i][j] == c_matrix[i][j])
				fprintf(stdout,"result[%d][%d] = %f\n", i, j, c_matrix[i][j]);
			else
				fprintf(stdout,"Error: result[%d][%d] = %f, expected = %f\n", 
						i, j, c_matrix[i][j], expected_c_matrix[i][j]);

		}
	}
	fprintf(stdout,"done\n");

#ifdef SW
	PTHREAD_CANCEL(mmultiply);
	PTHREAD_CANCEL(mmultiply_LL);
	PTHREAD_CANCEL(mmultiply_LH);
	PTHREAD_CANCEL(mmultiply_HH);
	PTHREAD_CANCEL(mmultiply_HL);
	close_pipe_handler();
#endif
}
コード例 #14
0
ファイル: testBestFit.c プロジェクト: arunkumarcea/ahir
int main(int argc, char* argv[])
{
	float result;
	int I;

	if(argc < 2)
	{
		fprintf(stderr,"Supply data set file.\n");
		return(1);
	}

	FILE* fp = fopen(argv[1],"r");
	if(fp == NULL)
	{
		fprintf(stderr,"Could not open data set file %s.\n", argv[1]);
		return(1);
	}

	signal(SIGINT,  Exit);
	signal(SIGTERM, Exit);

	PTHREAD_DECL(Logger);
	PTHREAD_CREATE(Logger);

#ifdef SW
	init_pipe_handler();
	PTHREAD_DECL(bestFit);
	PTHREAD_CREATE(bestFit);
#endif

	Sender();
	for(I = 0; I < NSAMPLES; I++)
	{
		double X;
		fscanf(fp, "%le", &X);
		write_float64("sample_data_pipe", X);
		samples[I] = X;
	}
	fprintf(stderr," Sent samples.\n");
	fclose(fp);

	calculateReferenceFit();

	uint32_t best_sigma_index = read_uint32("best_sigma_pipe");
	fprintf(stdout, " Best sigma= %f (index = %d).\n", (MIN_SIGMA + (best_sigma_index*(MAX_SIGMA - MIN_SIGMA)/NSIGMAS)), best_sigma_index);
	
	double p0 = read_float64("fit_coefficient_pipe");
	double p1 = read_float64("fit_coefficient_pipe");
	double p2 = read_float64("fit_coefficient_pipe");
	double p3 = read_float64("fit_coefficient_pipe");
	double p4 = read_float64("fit_coefficient_pipe");
	double p5 = read_float64("fit_coefficient_pipe");
	fprintf(stdout, "Fit coefficients = %le, %le, %le, %le, %le, %le.\n", p0,p1,p2,p3,p4,p5);

	uint32_t elapsed_time = read_uint32("elapsed_time_pipe");
	fprintf(stdout,"Elapsed time = %d.\n", elapsed_time);

#ifdef SW
	PTHREAD_CANCEL(bestFit);
	close_pipe_handler();
	return(0);
#endif
}