Programming/openMP2013. 11. 18. 21:55
openMP가 shared memory 구조를 지원한다고 하는데
다르게 말하면 함수나 block 구현시
private 메모리가 생성되는걸 응용하여 사용하는것 같은 느낌

그리고 이러한 공유 변수의 제어는 default 키워드를 이용하는데
default(shared)가 기본 값이고 none으로 할 경우 별도의 변수를 선언을 해주어야 한다.

#pragma omp parallel
default(shared|none)
private
firstprivate
lastprivate 

$ cat test.c
01#include "omp.h"
02 
03void thread()
04{
05        int res = 0;
06#pragma omp parallel default(none)
07{
08//      int res = 0;
09        // initialize
10        printf("res = %d\n",res);
11}
12}
13 
14int main(int argc, const char *argv[])
15{
16        thread();
17        return 0;
18}

gcc -fopenmp test.c -lm
test.c: In function ‘thread’:
test.c:16:8: error: ‘res’ not specified in enclosing parallel
test.c:12:9: error: enclosing parallel
make: *** [all] 오류 1 

'Programming > openMP' 카테고리의 다른 글

openMP atomic과 critical  (0) 2013.11.26
openMP single 과 master의 차이점  (0) 2013.11.26
openMP gnu implement  (0) 2013.11.11
openMP example  (0) 2013.09.29
openMP로 구현한 야매 sum()  (0) 2013.09.25
Posted by 구차니