- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include
#include
#include
#include
#define MAX 10000
void qsort(void);
void quicksort(int a[],int lo,int hi);
int main()
{
FILE *fp;
int i,n=0,j;
int a[MAX];
clock_t start,stop;
char ar[MAX];double startTime,endTime;
printf("Enter the file name \n");
scanf("%s",ar);
if((fp=fopen(ar,"r"))==NULL)
{
printf("Can't open file.\n");
exit(1);
}
i=fscanf(fp,"%d",&a
while(i != EOF)
{
n++;
i=fscanf(fp,"%d",&a
}
fclose(fp);
startTime = omp_get_wtime( );
start = clock( );
printf("\nn=%d,\nstart time=%10.9f\n",n,(((double)(start))/CLOCKS_PER_SEC));
quicksort(a,0,n-1);
stop = clock();
endTime=omp_get_wtime( );
printf("Elapsed time=%10.5f",endTime-startTime);
printf("\nstop=%10.9f\n",(((double)(stop))/CLOCKS_PER_SEC));
printf("Time taken :%10.9f sec",(((double)(stop-start))/CLOCKS_PER_SEC));
}
void quicksort(int a[],int lb,int ub)
{
int i,j,temp,key,flag=1;
if ( lb < ub )
{
i = lb;
j = ub + 1;
key = a [ lb ];
while ( flag )
{ i++;
while(a < key && i < ub )
i++;
j--;
while ( a [ j ] > key)
j--;
if ( i < j )
{
temp = a;
a = a
a
}
else
flag = 0;
}
a[lb]=a
a
#pragma omp parallel sections
{
#pragma omp section
{ if(lb<(j-1))
quicksort(a,lb,j-1);
}
#pragma omp section
{
if ((j+1)
}
}
}
}
sorry !I had not submitted the full code.
Even when itestwith 1100 numbers there is no difference in the start and stop time(I am working on dual core machine). Please can anybody tell me why .
Which time functions I must use for serial codes to find elapsed time.(I am using intel C++)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://en.allexperts.com/q/C-1040/time-milliseconds-Windows.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
loop until timer increases
display time
loop....
I'd be disappointed if omp_get_wtime() doesn't resolve intervals of 1 millisecond or less. On linux, where it typically is a wrapper for gettimeofday(), it's significantly better than that, but not as good as timers such as Windows QueryPerformanceCounter() or __rdtsc().
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page