Example #1
0
void * pi_a() {
	int coid;
	int rcvid;

	char send[50] = "PI_A";
	char receive[50];

	int from;
	int to;
	double result;

	int status = 0;

	coid = ConnectAttach(0, pid, chid, 0, NULL);
	checkresult(coid, "\nConnect Attach failed in PI_A: ");

	printf("PI_A: connected to channel (Connect ID = %i) \n", coid);

	while (status == 0){
		status = MsgSend(coid, &send, sizeof(send), &from, sizeof(double));
		status = MsgSend(coid, &send, sizeof(send), &to, sizeof(double));

		k = 0, pi_old = 0, pi = 0;

		for(k = from; k <= to;k++){
			pi = pi_old + 4 * (pow(-1, k+1)) / (2*k -1);
			pi_old = pi;
		}

		status = MsgSend(coid, &pi, sizeof(double), &receive, sizeof(receive));
	}

	return(NULL);
}//end pi
Example #2
0
/* Run f and return clocks per inner loop iteration */
double run(test_funct f, int n)
{
    double cpi;

    cpi = fcyc(f, n, CLEARCACHE) / (n*n*n);
    checkresult(gc, n);
    return(cpi);
}
Example #3
0
int main(int argc, char ** argv){
	int result;

	if(argc != 3){
		printf("wrong args: pi_a pid chid \n");
		exit(-1);
	}

	pid = atoi(argv[1]);
	chid = atoi(argv[2]);

	printf("\nChannel PID = %i\n", pid);
	printf("\nChannel 1 CHID = %i\n", chid);

	result = pthread_create(NULL, NULL, &pi_a, NULL);
	checkresult(result, "Thread creation failed\n");

	pthread_join(2, NULL);

	return 0;
}//end main
Example #4
0
File: test.c Project: fdy84/amulet
int main()
{
    gVar = (int *)malloc((sizeof(int))*CL*RTN);
    
    
    inittest();
    
    
    
    gq = Queue_new();
    
    t0 = clock();
    
    printf("Starting Test 1 ...\n");
    
    start_multi(0);
    
    wait_multi();
    
    //t2 = clock();
    
    //if ( checkresult != 0 )
    //    return -1;
    
    printf("TEST 1 , Multi In.\n");
    printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    //printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    t0 = clock();
    
    printf("Starting Test 2 ...\n");
    
    start_multi(1);
    
    wait_multi2();
    
    //t1 = clock();
    
    if ( checkresult() != 0 )
        return -1;
    
    printf("TEST 2 , Multi Out.\n");
    //printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    
    inittest();
    
    
    
    
    gq = Queue_new();
    
    t0 = clock();
    
    printf("Starting Test 3 ...\n");
    
    start_multi(0);
    
    single_get();
    
    t2 = clock();
    
    wait_multi();
    
    if ( checkresult() != 0 )
        return -1;
    
    printf("TEST 3 , Multi In Single Out.\n");
    printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    
    
    inittest();
    
    
    
    
    gq = Queue_new();
    
    t0 = clock();
    
    printf("Starting Test 4 ...\n");
    
    single_put();
    
    t1 = clock();

    printf("TEST 4 , Single In .\n");
    printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    //printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    t0 = clock();
    
    printf("Starting Test 5 ...\n");
    
    start_multi(2);
    
    wait_multi2();
    
    //t1 = clock();
    
    if ( checkresult() != 0 )
        return -1;
    
    printf("TEST 5 , Multi Out 2.\n");
    //printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    
    inittest();
    
    
    
    
    gq = Queue_new();
    
    t0 = clock();
    
    printf("Starting Test 6 ...\n");
    
    start_multi(0);
    start_multi(1);
    
    wait_multi();
    wait_multi2();
    
    if ( checkresult() != 0 )
        return -1;
    
    printf("TEST 6 , Multi In Multi Out.\n");
    printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    inittest();

    
    
    gq = Queue_new();
    
    t0 = clock();
    
    printf("Starting Test 7 ...\n");
    
    start_multi(0);
    start_multi(2);
    
    wait_multi();
    wait_multi2();
    
    if ( checkresult() != 0 )
        return -1;
    
    printf("TEST 7 , Multi In Multi Out 2.\n");
    printf("         PUT USE : %f seconds\n", (double)(t1 - t0) / CLOCKS_PER_SEC);
    printf("         GET USE : %f seconds\n", (double)(t2 - t0) / CLOCKS_PER_SEC);
    
    
    
    
    return 0;
}