кодВ VS2010 использование openMP firstprivate не удалось?
double t;
double limit = 10;
double result = 1000;
int i;
#pragma omp parallel sections default(none) firstprivate(result) lastprivate(result) private(t) shared(limit)
{
#pragma omp section
{
printf("Section1: result = %f\n", result);
result += 55;
printf("Section1: result = %f\n", result);
}
#pragma omp section
{
printf("Section2: result = %f\n", result);
result += 3628800;
printf("Section2: result = %f\n", result);
}
}
printf("result1 = %0.0lf\n", result);
В результате
Section1: result = 1000.000000
Section1: result = 1055.000000
Section2: result = 1000.000000
Section2: result = 3629800.000000
result1 = 3629800
ИЛИ
Section1: result = 1000.000000
Section1: result = 1055.000000
Section2: result = 1055.000000
Section2: result = 3629855.000000
result1 = 3629855
В VS2010, я использую firstprivate для инициализации result
в разделе.
Я думаю, что в section1 или разделе 2, результат должен быть 1000 перед операцией +
Однако результат может быть инициализирован в 1055 в разделе 2 при запуске программы. Может кто-нибудь сказать мне, почему?