0
這是我第一次嘗試OpenMP,但無法獲得加速。該機器是Linux amd_64。我編碼了以下代碼:無法獲得簡單OpenMP並行循環的速度
printf ("nt = %d\n", nt);
omp_set_num_threads(nt);
int i, j, s;
#pragma omp parallel for private(j,s)
for (i=0; i<10000; i++)
{
for (j=0; j<100000; j++)
{
s++;
}
}
And the compile with
g++ tempomp.cpp -o tomp -lgomp
And run it with different nthreads, no speedup:
nt = 1
elapsed time =2.670000
nt = 2
elapsed time =2.670000
nt = 12
elapsed time =2.670000
任何想法?
嗨謝謝,這解決了問題!我有12個內核。 –