왜 OpenMP를 나에게이 오류 줄 않습니다 -의 OpenMP는
가오류 : 전에 예상 문 '{'토큰
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
#pragma omp parallel
{
int a[100],b[100],c[100];
int i =0;
for(; i < 100; i++){
a[i] = i;
b[i] = i;
}
#pragma omp parallel for schedule(static,5)
{
int i = 0;
for(; i < 100 ; i++){ // this is the for loop that is referred in the error message
c[i] = a[i] + b[i];
}
}
}
printf("Outside parallel block \n");
}
나는 이것을 생각 해왔다. 내 우려는, 'i'가 각 스레드마다 개별 스레드 대신 다른 스레드에 대한 공유 변수가되는 경우입니다. 같은 변수에 쓰는 스레드가 다르기 때문에 결과가 엉망이됩니까? – r3x
@julianromera 예. 이 대답은 올바른 것으로하기 위해서 '사적 (i)'이라고 기술 할 필요가있다. – NoseKnowsAll