C, pgcc - automatic parallelization "not countable"
I use this for loop, which I want to have parallelizide automaticaly, it is used for count of PI number:
piece=1.0/100000;
for (t=0.0; t<1.0; t=t+piece){
x=t+piece/(float)2;
if(x<=1.0){
开发者_JAVA技巧 integral=4/(1+x*x);
sum=sum+integral;
}
}
This is doint partial sum for all values in interval 0-1. Then I made from it PI value. But this is not the problem, problem is, when I use automatic parallelization with pgcc, I set up number of processes but I am told that "Loop not vectorized/parallelized: not countable" when I am compiling my program. I have tried everything, but still no change. Any ideas? Thanks
Your loop variable is a double, try changing the code so it uses an integer:
for (int t = 0; t < 100000; t++) {
x=(t/100000.0)+piece/(float)2;
if(x<=1.0){
integral=4/(1+x*x);
sum=sum+integral;
}
}
I'm guessing this is because your loop counter is a float
or double
. Try using an integral counter.
int step;
for (step = 0; step < 100000; step++) {
// determine x from step
...
}
精彩评论