public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49575] New: OpenMP has a problem with -funroll-loops
@ 2011-06-29  9:46 sailorweb2 at hotmail dot com
  2011-06-29 18:41 ` [Bug c++/49575] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sailorweb2 at hotmail dot com @ 2011-06-29  9:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49575

           Summary: OpenMP has a problem with -funroll-loops
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sailorweb2@hotmail.com


-funroll-loops optimisation option does not work on OpenMP in some cases.
Attached an example. Compiled with options

g++ -g -O2 -funroll-loops -fomit-frame-pointer -march=native -fopenmp

On a 4-core single Intel CPU machine with Kubuntu 11.04, the following program
compiled with OpenMP is around 20 times slower than the program compiled
without OpenMP, because -funroll-loops option does not work on the OpenMP
version. Defining k variable as constant or moving its declaration to inside
the for loop can solve the problem, but they should not be necessary. I think
-funroll-loops should work on the following program as it is.


#include <math.h>
#include <iostream>

using namespace std;

int main ()
{
  long double i=0;
  long double k=0.7;

  #pragma omp parallel for firstprivate(k) reduction(+:i)
  for(int t=1; t<300000000; t++){       
    for(int n=1; n<16; n++){
      i=i+pow(k,n);
    }
  }

  cout << i<<"\t";
  return 0;
}

Initial discussion on this topic was at
http://stackoverflow.com/questions/6506987/why-openmp-version-is-slower


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-16  0:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-29  9:46 [Bug c++/49575] New: OpenMP has a problem with -funroll-loops sailorweb2 at hotmail dot com
2011-06-29 18:41 ` [Bug c++/49575] " jakub at gcc dot gnu.org
2011-06-29 19:38 ` sailorweb2 at hotmail dot com
2011-06-29 19:50 ` jakub at gcc dot gnu.org
2011-12-16  0:43 ` [Bug middle-end/49575] " pinskia at gcc dot gnu.org

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).