I have to snippets, one of which is standard, and one other which uses OpenMP. This is the first:
#include <iostream>
int main(){
double a = 0;
for(int i =0; i<= 100000; i++){
a+=1;
}
std::cout << a << std::endl;
return 0;
}
This code gives me: 100001, so it is OK; there is no problem.
The problem is that, for the second snippet:
#include <iostream>
int main(){
double a = 0;
#pragma omp parallel for
for(int i = 0; i<=100000; i++){
a+=1;
}
std::cout << a << std::endl;
return 0;
}
The result of this code is: 55246, and I don't know why I get this result instead of 100001.