第九章 通用核心回顾
- 创建线程组:
- shared(list)
- private(list)
- firstprivate(list)
- default(none)
- reduction(operator:list)
#pragma omp parallel [clause[,clause]...]
{
//body of parallel
}
- 共享工作循环构造:
- private(list)
- firstprivate(list)
- nowait
- reduction(operator:list)
- schedule(kind[,chunk_size])
#pragma omp for [clause[,clause]...]
//for-loop
- single构造:
- private(list)
- firstprivate(list)
- nowait
#pragma omp single [clause[,clause]...]
{
//body of single
}
- 组合式并行共享工作循环构造:
- shared(list)
- private(list)
- firstprivate(list)
- reduction(operator:list)
- schedule(kind[,chunk_size])
#pragma omp parallel for [clause[,clause]...]
//for-loop
- 创建显式任务:
- shared(list)
- private(list)
- firstprivate(list)
- default(none)
#pragma omp task [clause[,clause]...]
{
//body of task
}
- 任务等待指令:
#pragma omp taskwait
- 栅栏指令:
#pragma omp barrier
- 临界区构造:
#pragma omp critical
{
//body of critical
}
-
常用的数据环境子句:
- shared(list)
- private(list)
- firstprivate(list)
-
归约子句:
- reduction(operator:list)
运算符 | 初始值 |
---|---|
+ | 0 |
* | 1 |
- | 0 |
min | 最大正数 |
max | 最大负数 |
- 设置默认并行区域请求线程数的环境变量:
OMP_NUM_THREADS list
- 设置后继并行区域的默认请求线程数:
void omp_set_num_threads(int num_threads);
- 返回最内围并行区域当前组的线程数:
int omp_get_num_threads(void);
- 返回最内围并行区域当前组内调用线程的线程号:
int omp_get_thread_num(void);
- 返回经过的墙钟时间:
double omp_get_wtime(void);
标签:firstprivate,回顾,第九章,clause,list,private,omp,pragma,OpenMP
From: https://www.cnblogs.com/mesonoxian/p/17985907