Skip to content
Snippets Groups Projects
Commit 352e86db authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 2be85af8
Branches
No related tags found
No related merge requests found
Pipeline #3765 passed
...@@ -15,7 +15,6 @@ double pi; ...@@ -15,7 +15,6 @@ double pi;
void main() { void main() {
int i; int i;
printf("%d\n",omp_get_max_threads());
double a,b,c,dt,mflops; double a,b,c,dt,mflops;
struct timespec tstart,tend; struct timespec tstart,tend;
clock_gettime(CLOCK_REALTIME,&tstart); clock_gettime(CLOCK_REALTIME,&tstart);
...@@ -24,13 +23,12 @@ void main() { ...@@ -24,13 +23,12 @@ void main() {
c = 0.25; c = 0.25;
pi = 0; pi = 0;
pi = 0; pi = 0;
#pragma omp parallel #pragma omp parallel for reduction(+:pi)
#pragma omp for reduction(+:pi)
for (i = 1; i <= NPTS; ++i) for (i = 1; i <= NPTS; ++i)
pi += a/((i-b)*(i-c)); pi += a/((i-b)*(i-c));
clock_gettime(CLOCK_REALTIME,&tend); clock_gettime(CLOCK_REALTIME,&tend);
dt = (tend.tv_sec+tend.tv_nsec/1e9)-(tstart.tv_sec+tstart.tv_nsec/1e9); dt = (tend.tv_sec+tend.tv_nsec/1e9)-(tstart.tv_sec+tstart.tv_nsec/1e9);
mflops = NPTS*5.0/(dt*1e6); mflops = NPTS*5.0/(dt*1e6);
printf("NPTS = %d, pi = %f\n",NPTS,pi); printf("NPTS = %d, pi = %f, threads = %d\n",NPTS,pi,omp_get_max_threads());
printf("time = %f, estimated MFlops = %f\n",dt,mflops); printf("time = %f, estimated MFlops = %f\n",dt,mflops);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment