Skip to content
Snippets Groups Projects
Select Git revision
  • d9ba56c295f057e716519a798bf9cdb4898c24f4
  • master default protected
  • v0.10.0
  • v0.10.0-rc2
  • v0.10.0-rc1
  • v0.9.0
  • v0.9.0-rc1
  • v0.8.0
  • v0.8.0-rc2
  • v0.8.0-rc1
  • v0.7.0
  • v0.7.0-rc2
  • v0.7.0-rc1
  • v0.6.1
  • v0.6.0
  • v0.6.0-rc2
  • v0.6.0-rc1
  • v0.5.0
  • v0.5.0-rc2
  • v0.5.0-rc1
  • v0.4.0
  • v0.4.0-rc2
22 results

NEWS-0.4.0

Blame
  • To find the state of this project's repository at the time of any of these versions, check out the tags.
    mppi.c 798 B
    /*
    * mppi.c
    * Neil Gershenfeld 6/21/19
    * OpenMPI pi calculation benchmark
    * pi = 3.14159265358979323846
    */
    
    #include <stdio.h>
    #include <time.h>
    #include <omp.h>
    
    #define NPTS 1000000000
    
    double pi;
    
    void main() {
       int i;
       printf("%d\n",omp_get_max_threads());
       double a,b,c,dt,mflops;
       struct timespec tstart,tend;
       clock_gettime(CLOCK_REALTIME,&tstart);
       a = 0.5;
       b = 0.75;
       c = 0.25;
       pi = 0;
       pi = 0;
       #pragma omp parallel
       #pragma omp for reduction(+:pi)
       for (i = 1; i <= NPTS; ++i)
          pi += a/((i-b)*(i-c));
       clock_gettime(CLOCK_REALTIME,&tend);
       dt = (tend.tv_sec+tend.tv_nsec/1e9)-(tstart.tv_sec+tstart.tv_nsec/1e9);
       mflops = NPTS*5.0/(dt*1e6);
       printf("NPTS = %d, pi = %f\n",NPTS,pi);
       printf("time = %f, estimated MFlops = %f\n",dt,mflops);
       }