[Bug libgomp/32789] New: Profiling not possible with -fopenmp
jensseidel at users dot sf dot net
gcc-bugzilla@gcc.gnu.org
Tue Jul 17 08:49:00 GMT 2007
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
More information about the Gcc-bugs
mailing list