我的问题是我没有与openMP并行化。与openMP没有并行线程
我的系统: ubuntu的11.4 英特尔(R)核心(TM)15 CPU中号430 @ 2.27GHz
编译器: 克++版本:4.5.2 与标志-fopenmp
有了这个代码中,我看到有只有一个线程:
int nthreads, tid, procs, maxt, inpar, dynamic, nested;
// Start parallel region
#pragma omp parallel private(nthreads, tid) {
// Obtain thread number
tid = omp_get_thread_num();
// Only master thread does this
if (tid == 0)
{
printf("Thread %d getting environment info...\n", tid);
// Get environment information
procs = omp_get_num_procs();
nthreads = omp_get_num_threads();
maxt = omp_get_max_threads();
inpar = omp_in_parallel();
dynamic = omp_get_dynamic();
nested = omp_get_nested();
// Print environment information
printf("Number of processors = %d\n", procs);
printf("Number of threads = %d\n", nthreads);
printf("Max threads = %d\n", maxt);
printf("In parallel? = %d\n", inpar);
printf("Dynamic threads enabled? = %d\n", dynamic);
printf("Nested parallelism supported? = %d\n", nested);
}
}
,因为我看到下面的输出:
Number of processors = 4
Number of threads = 1
Max threads = 4
In parallel? = 0
Dynamic threads enabled? = 0
Nested parallelism supported? = 0
什么问题?
有人可以帮忙吗?
您是否设置了OMP_NUM_THREADS环境变量? –
嘿! 不,我没有。但做完omp_set_num_threads(2)后; 我得到以下输出: 数量的处理器= 4 线程= 1个 最大线程= 2 在并行数? = 0 启用动态线程? = 0 支持嵌套并行? = 0 线程数仍然是1. – Sankp