Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

OpenMP bug in compiler

quince
Beginner
652 Views
Consider a class with interface declared in a separate .h file, with the following private variable:
long const dim;

Now, in a member function of the class in the .cpp file I have:
#pragma omp parallel for
for (long i = dim; i <= dd; i += dim)
.....

Then the following happens:
error: An OpenMP "for" must have a loop-invariant increment of integer type

The only way I got it to work is by adding before the pragma this:
long const dim(dim);

It seems the compiler is unable to take into account that dim is already a const as declared in the header, and I need to resort to this stupid looking fix.

Message Edited by Quince on 09-12-2005 05:57 PM

0 Kudos
7 Replies
Maximillia_D_Intel
652 Views

Hi,

What compiler are you using?

Any chance you could post a small cut down here?

That said, assuming it is a problem in the compiler, the best route to get this addressed is to file a premier support issue. Can you do so?

Thanks,

Max

0 Kudos
quince
Beginner
652 Views
The compiler version is 9.
.h file:
class ART
{
public:
...
...
private:
...
...
long const dim;
...
...
};

.cpp file:
bool ART::MoveZig(float const img[])
{
...
...
long const dd(dim * dim);
float const fd2(static_cast(dim) / 2.0f - 0.5f), fh2(static_cast(hght) / 2.0f - 0.5f);
#pragma omp parallel for
for (long i = dim; i <= dd; i += dim)
{
long k;
if (sw) k = 6 * (dd - i);
else k = 6 * (i - dim);

for (long j = i - dim; j < i; ++j, k += 6)
{
... // No use of dim here
...
}
}
...
...
}

Compiling with icpc:
error: An OpenMP "for" must have a loop-invariant increment of integer type
for (long i = dim; i = dd; i += dim)
^

If, before the loop, I add:
long const dim(dim);

Then it compiles fine...

Message Edited by Quince on 09-20-2005 12:43 PM

0 Kudos
Maximillia_D_Intel
652 Views

Hi,

A developer was curious and confirmedthe problem. For best results and proper prioritization, I'd like to encourage you to submit a premier support issue if you have not done so.

Thanks,

Max

0 Kudos
quince
Beginner
652 Views
I think I may have found another issue. From what I read about OpenMP, the master thread always has ID equal to 0. But when I have this in a function that is called many times:
#pragma omp parallel
long const th(omp_get_thread_num());
#pragma omp master
{
if (th != 0) exit(0);
...
}
}


On random occasions the condition becomes true, i.e. we have a thread ID of a master thread that is not 0.
0 Kudos
Maximillia_D_Intel
652 Views

Hi,

Any chance you could submit a Premier support issue?

thanks,

Max

0 Kudos
quince
Beginner
652 Views
Sorry, I'm not sure how to do that. I don't find it when I search the website for 'premier support'.
0 Kudos
Maximillia_D_Intel
652 Views

Hi,

For best results, try premier.intel.com

A developer may get curious and try out the code just from what you have posted, but I can make no guarantees. Any chance you could post the full testcase here?

Regards,

Max

Message Edited by mjdomeik on 09-27-2005 09:56 PM

0 Kudos
Reply