Example #1
0
int main()
{
	double execTime = 0.0;
	double startTime, endTime;

    int k, size1, size2;

// Tell the compiler to align the a, b, and x arrays on 16-byte
// boundaries.  This allows the vectorizer to use aligned instructions
// and produce faster code.
#ifdef ALIGNED
#ifdef _WIN32
	_declspec(align(16)) FTYPE a[ROW][COLWIDTH];
    _declspec(align(16)) FTYPE b[ROW];
    _declspec(align(16)) FTYPE x[COLWIDTH];
#else
	FTYPE a[ROW][COLWIDTH]	__attribute__((aligned(16)));
	FTYPE b[ROW]			__attribute__((aligned(16)));
	FTYPE x[COLWIDTH]		__attribute__((aligned(16)));
#endif // _WIN32
#else
	FTYPE a[ROW][COLWIDTH];
	FTYPE b[ROW];
	FTYPE x[COLWIDTH];
#endif
	size1 = ROW;
	size2 = COLWIDTH;

    printf("\nROW:%d COL: %d\n",ROW,COLWIDTH);

    // initialize the arrays with data
	init_matrix(ROW,COL,1,a);
	init_array(COL,3,x);

	//start timing the matrix multiply code
	startTime = clock_it();
	for (k = 0;k < REPEATNTIMES;k++) {
#ifdef NOFUNCCALL
        int i, j;
		for (i = 0; i < size1; i++) {
			b[i] = 0;
			for (j = 0;j < size2; j++) {
				b[i] += a[i][j] * x[j];
			}
		}
#else
		matvec(size1,size2,a,b,x);
#endif
		x[0] = x[0] + 0.000001;
	}
	endTime = clock_it();
	execTime = endTime - startTime;

	printf("Execution time is %2.3f seconds\n", execTime);
	printf("GigaFlops = %f\n", (((double)REPEATNTIMES * (double)COL * (double)ROW * 2.0) / (double)(execTime))/1000000000.0);
	printsum(COL,b);

	return 0;
}
Example #2
0
void main() {
	struct treenode *root = getnode(5);
	root->left = getnode(4);
	root->left->left = getnode(3);
	root->left->right= getnode(8);
	root->right= getnode(7);
	root->right->left = getnode(6);
	root->right->right= getnode(9);

	struct listnode *node = getlistnode();
	get_vertical_sum(root, node);
	printsum(node);
}
Example #3
0
/* USAGE: keccaksum <digest_size> <files> */
int main(int argc, char **argv){
    register int i;
    size_t digestsize;

    /* First check to see if all our base is in order */
    if(argc < 2){
        printf("Usage: %s <digest_size> <files>\n", argv[0]);
        return -1;
    } else if(argc == 2){
        sscanf(argv[1], "%lu", &digestsize);
        printsum("-", stdin, digestsize / 8);
    } else {
        sscanf(argv[1], "%lu", &digestsize);
        for(i = 2; i < argc; i++){
            if(strcmp(argv[i], "-") == 0) printsum("-", stdin, digestsize / 8);
            else if(access(argv[i], F_OK) != 0) fprintf(stderr, "Error: could not find %s\n", argv[i]);
            else if(access(argv[i], R_OK) != 0) fprintf(stderr, "Error: cannot read %s\n", argv[i]);
            else printsum(argv[i], fopen(argv[i], "r"), digestsize / 8);
        }
    }

    return 0;
}
Example #4
0
void fsprocess()
{
	pid=fork();
   	if (pid==-1)
	{
		printf("error in fork!");
		exit(-1);
	}
   	else if(pid)  
	{
        wait();
   		printsum();
   		exit(0) ;
	} 
	else 
	{
   		CountLetter();
   		exit(0);
	}
}