gomp-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gomp-discuss] Work in progress ....


From: Lars Segerlund
Subject: Re: [Gomp-discuss] Work in progress ....
Date: Mon, 19 May 2003 10:57:05 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.3) Gecko/20030430 Debian/1.3-5


 Thank you, I will start wokring on this one :-)

 / Lars

Biagio Lucini wrote:
On Fri, 16 May 2003, Lars Segerlund wrote:


 Ok, so a lot of people is down :-( ...

  Does anybody have some 'trivial' cases for OpenMP ? ( examples ) and
I will try to get some time to patch together a set of 'hardcoded
backend drivers' which generates some code for these ?



Below what I promised before. It takes ~ 32 sec. on a PIII 800Mhz, ~19sec
in the dual processor case. Tested with the Portland group compiler.
Uncomment the lines with NUM_THREADS if the compiler defaults the num of
threads to 1 instead of the num of CPUS.

Biagio

==========================================================================
#include <stdlib.h>
#include <stdio.h>
#include <omp.h>
/* #define NUM_THREADS 2 */
#define intervals 1000000000


int main()
{
  double width, sum;
  int i;
  double x;

  /* omp_set_num_threads(NUM_THREADS); */

  width = 1.0 / intervals;

  /* do the computation */
  sum = 0.0;
#pragma omp parallel for default(shared) private(i,x) reduction(+: sum)
  for (i=0; i<intervals; ++i) {
    x = (i + 0.5) * width;
    sum += 4.0 / (1.0 + x * x);
  }
  sum *= width;

  printf("Estimation of pi is %f\n", sum);

  return 0;
}


_______________________________________________
Gomp-discuss mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/gomp-discuss






reply via email to

[Prev in Thread] Current Thread [Next in Thread]