我的問題是我沒有與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