public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom St Denis <tstdenis@ellipticsemi.com>
To: diego sandoval <diego.sandoval@cif.org.co>
Cc: gcc-help@gcc.gnu.org
Subject: Re: openMP gcc vs icc, erratic results with gcc
Date: Wed, 21 May 2008 15:23:00 -0000	[thread overview]
Message-ID: <48340769.7080602@ellipticsemi.com> (raw)
In-Reply-To: <faa182c80805210034u12afd7fepaa08e5dfce69b7eb@mail.gmail.com>

diego sandoval wrote:
> int main(int argc, char *argv[])
> {
>   double start, stop; /* times of beginning and end of procedure */
>   double e, pi, factorial, product;
>   int i;
>
>       for (i = 1; i<num_steps; i++) {
>
> 	factorial *= i;
> 	e += 1.0/factorial;
>       }
>   
>       for (i = 0; i < num_steps*10; i++) {
> 	/* we want 1/1 - 1/3 + 1/5 - 1/7 etc.
> 	   therefore we count by fours (0, 4, 8, 12...) and take
>              1/(0+1) =  1/1
> 	   - 1/(0+3) = -1/3
>
>              1/(4+1) =  1/5
> 	   - 1/(4+3) = -1/7 and so on */
> 	pi += 1.0/(i*4.0 + 1.0);
> 	pi -= 1.0/(i*4.0 + 3.0);
>       }
>   

Aren't they both competing for i?  Admittedly I don't know how OpenMP 
does it's threading (I'd just use pthreads) but both are using "i".

Try bringing it inside the blocks and see if that changes anything.

Tom

      reply	other threads:[~2008-05-21 11:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-21 11:29 diego sandoval
2008-05-21 15:23 ` Tom St Denis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48340769.7080602@ellipticsemi.com \
    --to=tstdenis@ellipticsemi.com \
    --cc=diego.sandoval@cif.org.co \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).