OpenMP を使用した for ループの進行状況を知りたいです。リダクション ディレクティブが機能しないことはわかっていますが、次のように書きました。
#pragma omp for reduction (+:sum)
for (int i=0; i < size; i++){
// do something that takes about 10seconds
sum++;
#pragma omp critical
cout << sum << " / " << size << endl;
}
これは次のようなものを返します:
1 / 100
1 / 100
2 / 100
1 / 100
...
しかし、私はこれが欲しい:
1 / 100
2 / 100
3 / 100
. ..
ディレクティブ中に正しいsum
値を取得する方法はありますか? reduction
または別の方法を使用する必要がありますか?