/************************************************************************* C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example : omp-loop-invert.c Objective : Write an OpenMP Program to demonstrate Performance improvement by doing the loop inverting. Input : a) Number of threads b) Size of matrices (numofrows and noofcols ) Output : Time taken for the computation. Created : August-2013 E-mail : hpcfte@cdac.in ************************************************************************/ #include #include #include #include #include /* Main Program */ main(int argc,char **argv) { int i,j,Noofthreads,Matsize; float **Matrix; struct timeval TimeValue_Start, TimeValue_Start1; struct timezone TimeZone_Start, TimeZone_Start1; struct timeval TimeValue_Final, TimeValue_Final1; struct timezone TimeZone_Final, TimeZone_Final1; long time_start, time_end; double time_overhead1,time_overhead2; printf("\n\t\t---------------------------------------------------------------------------"); printf("\n\t\t Centre for Development of Advanced Computing (C-DAC)"); printf("\n\t\t Email : hpcfte@cdac.in"); printf("\n\t\t---------------------------------------------------------------------------"); printf("\n\t\t Objective : OpenMP Program to demonstrate Performance improvement "); printf("\n\t\t by doing the loop inverting. ."); printf("\n\t\t..........................................................................\n"); /*i Checking for command line arguments */ if( argc != 3 ){ printf("\t\t Very Few Arguments\n "); printf("\t\t Syntax : exec \n"); exit(-1); } Noofthreads=atoi(argv[1]); Matsize=atoi(argv[2]); if ((Noofthreads!=1) && (Noofthreads!=2) && (Noofthreads!=4) && (Noofthreads!=8) && (Noofthreads!= 16) ) { printf("\n Number of threads should be 1,2,4,8 or 16 for the execution of program. \n\n"); exit(-1); } /* printf("\n\t\t Enter the size of the Matrix \n"); scanf("%d",&Matsize);*/ printf("\n\t\t Threads : %d",Noofthreads); printf("\n\t\t Matrix Size : %d",Matsize); /* Read the input */ Matrix = (float **)malloc( Matsize *sizeof(float *)); for(i=0 ; i