#pragma omp threadprivate(alpha)

2016-12-30 19:45:02来源:作者:人点击

#include <omp.h>int alpha[10],beta[10],i;#pragma omp threadprivate(alpha)main(){/* first parallel region */#pragma omp parallel private(i,beta){   int id ;    id = omp_get_thread_num();    for(i=0;i<10;i++)        alpha[i] = beta[i] = id * i;}/* second parallel region */#pragma omp parallel    printf("I am thread %d :alpha[3] = %d and beta[3] = %d/n", omp_get_thread_num(),alpha[3],beta[3]);}
I am thread 0 :alpha[3] = 0 and beta[3] = 0I am thread 3 :alpha[3] = 9 and beta[3] = 0I am thread 2 :alpha[3] = 6 and beta[3] = 0I am thread 1 :alpha[3] = 3 and beta[3] = 0

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台