I got the following output with error message while executing the program that uses openmp in VS2008 C++
thread number: 0
thread number: 1
Fatal User Error 1002: 'for' loop executed with inconsistent parameters between threads
My program does the following:
omp_set_dynamic(0);
omp_set_num_threads(2);
int i = 0;
int start_pos = 0;
int end_pos = 0;
pragma omp parallel default(none) private(i, start_pos, end_pos)
{
int nThreadNum = omp_get_thread_num();
printf("thread number: %d\n", nThreadNum);
start_pos = 0;
end_pos = (number_of_model_points / 2 + 1);
if (nThreadNum != 0) {
start_pos = (number_of_model_points / 2) + 1;
end_pos = (number_of_model_points);
}
pragma omp for
for(i = start_pos; i < end_pos; i++) {
...some code here...
}
}
What is the problem here? Please correct me if I made a mistake.