设为首页 加入收藏

TOP

#pragma omp threadprivate(alpha)
2016-12-31 08:14:42 】 浏览:89
Tags:#pragma omp threadprivate alpha

#include 

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] = 0
I am thread 3 :alpha[3] = 9 and beta[3] = 0
I am thread 2 :alpha[3] = 6 and beta[3] = 0
I am thread 1 :alpha[3] = 3 and beta[3] = 0
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++项目目录组织结构 下一篇一种scanf

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

最新文章

热门文章

C 语言

C++基础

windows编程基础

linux编程基础

C/C++面试题目