Odd error: "invalid controlling predicate" whilst using OpenMP

Aug 4, 2010 at 1:58am
Hey guys. I'm using g++-4.2 on a Mac (not my choice, I hope steve jobs dies in a fire).

I compile some pretty simple code:

1
2
3
4
5
6
7
8
9
10
11
12
using namespace std;
#include <iostream>

int main(){
	cout << endl;
	#pragma omp parallel for
	for(int i=0;i<1e5;i++)
		cout << "yeah! ";
	
	cout << "\n\n\n";
	return 0;
}  


With the command:

mayer:multiprocess declan$ g++ -o qtestrun tester.cpp -fopenmp

And I'm given the error:

1
2
tester.cpp: In function ‘int main()’:
tester.cpp:7: error: invalid controlling predicate


Line 7 being the one with for(...).

I've googled, but to no avail. Seems to be only people submitting bugs, but chances are it's something stupid I'm doing. Does anyone have any idea? I have g++-4.2, which supports OpenMP, I'm using the -fopenMP flag, and my example is verbatim from a working one. I honestly have no idea what to do. I'll try when I go home tonight on a linux machine.

Any suggestions?

Thanks!
Aug 4, 2010 at 3:47am
Well, very strange. I did the same exact thing on my home computer (a linux machine) and it gave me the same error. Then I just tried it again, and it worked..? Here is the code that's working now, compiling with the same command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using namespace std;
#include <iostream>
#include <omp.h>

int main(){

#pragma omp parallel for
for(int i=0;i<1000000;i++){
        if(i%10000==0)
                cout << endl << i << " from thread : " << omp_get_thread_num();
}

return 0;
}


(ignore the omp.h, it was working fine before. I need that to use omp_get_thread().)

Now I get:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[mlorp@arch testopenmp]$ ./runme 


0500000 from thread :  from thread : 10
510000 from thread : 1
10000 from thread : 0
520000 from thread : 1
20000 from thread : 0
530000 from thread : 1
30000 from thread : 0
540000 from thread : 1
40000 from thread : 0
550000 from thread : 1
50000 from thread : 0
560000 from thread : 1


And so on. But what the hell? I didn't change anything!
Aug 4, 2010 at 3:59am
But it is not tquite the same though:

you now have 1000000 where previously you had 1e5
Aug 4, 2010 at 4:13am
is it me, or should that be 10e5 anyways?

1e(n) = 1 for all n.
Aug 4, 2010 at 2:44pm
guestgulkan, by jeebus, you're right. That's the problem. What the hell? Can you not use that form in loops? Hmmm, I just checked. It works fine normally, but when you have the OpenMP #pragma, it doesn't like things of the form 3e8! Weird.

Phantom139, no. aex is a*10^x. It wouldn't be very handy if it was the way you said.
Aug 4, 2010 at 3:44pm
ah, right, I mixed that up with the power function, my bad.
Topic archived. No new replies allowed.