public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/32789]  New: Profiling not possible with -fopenmp
@ 2007-07-17  8:49 jensseidel at users dot sf dot net
  2007-07-17  9:55 ` [Bug libgomp/32789] " theodore dot papadopoulo at sophia dot inria dot fr
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: jensseidel at users dot sf dot net @ 2007-07-17  8:49 UTC (permalink / raw)
  To: gcc-bugs

Hi,

I noticed that profiling data are wrong if OpenMp is used via
-fopenmp.

I have only two #pragma omp parallel statements in a class and the
calling statistic of this class contructor is completly wrong (gprof
tells me this constructor is called far too often).

I found bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29935
related to OpenMP and profiling but it seems to be a different issue.

I tried to reproduce it on a minimal example but could not get very
wrong results. Nevertheless I have a simple example which results in
different profiling data depending on the -fopenmp option:

#include <vector>

class VectorStuff
{
public:
  VectorStuff()
  {
  }

  void AddVectors(int n, const double *x1, const double *x2, double *y);
};

void VectorStuff::AddVectors(int n, const double *x1, const double *x2, double
*y)
{
  y = new double[n];
  #pragma omp parallel for
  for (int i=0; i<n; ++i)
    y[i] = x1[i] + x2[i];
}

int main()
{
  VectorStuff vec;
  const int n = 1000;
  std::vector<double> x1(n, -2), x2(n, 2);
  double *y;
  vec.AddVectors(n, &x1[0], &x2[0], y);
  return 0;
}

Comparig the output of
g++-4.2svn -pg -g -fopenmp main.cpp; ./a.out; gprof ./a.out > ./a.out.gprof1
g++-4.2svn -pg -g main.cpp; ./a.out; gprof ./a.out > ./a.out.gprof2

results in

--- a.out.gprof1        2007-07-17 10:47:04.000000000 +0200
+++ a.out.gprof2        2007-07-17 10:47:13.000000000 +0200
@@ -37,7 +37,6 @@
   0.00      0.00     0.00        2     0.00     0.00  void
std::_Destroy<double*, double>(double*, double*, std::allocator<double>)
   0.00      0.00     0.00        1     0.00     0.00 
VectorStuff::AddVectors(int, double const*, double const*, double*)
   0.00      0.00     0.00        1     0.00     0.00 
VectorStuff::VectorStuff()
-  0.00      0.00     0.00        1     0.00     0.00  main

  %         the percentage of the total running time of the
 time       program used by this function.

I agree that this is not very critical for this example, but for other
programs profiling is just useless.

$ c++-4.2svn --version
c++-4.2svn (GCC) 4.2.1 20070713 (prerelease)


-- 
           Summary: Profiling not possible with -fopenmp
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jensseidel at users dot sf dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

end of thread, other threads:[~2021-12-29  7:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-32789-4@http.gcc.gnu.org/bugzilla/>
2021-12-29  7:19 ` [Bug libgomp/32789] Profiling not possible with -fopenmp pinskia at gcc dot gnu.org
2007-07-17  8:49 [Bug libgomp/32789] New: " jensseidel at users dot sf dot net
2007-07-17  9:55 ` [Bug libgomp/32789] " theodore dot papadopoulo at sophia dot inria dot fr
2007-07-17 10:11 ` theodore dot papadopoulo at sophia dot inria dot fr
2007-07-17 10:24 ` pinskia at gcc dot gnu dot org
2007-07-17 10:24 ` jensseidel at users dot sf dot net
2007-07-17 10:26   ` Andrew Pinski
2007-07-17 10:27 ` pinskia at gmail dot com
2007-07-17 11:00 ` jensseidel at users dot sf dot net

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