Skip to content

Commit 5e0f626

Browse files
committed
fix reduction
1 parent 9e15ec5 commit 5e0f626

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tasks/example_threads/omp/src/ops_omp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ bool NesterovATestTaskOMP::RunImpl() {
3636
const int num_threads = ppc::util::GetNumThreads();
3737
GetOutput() *= num_threads;
3838

39-
std::atomic<int> counter(0);
40-
#pragma omp parallel default(none) shared(counter) num_threads(ppc::util::GetNumThreads())
41-
counter++;
39+
int counter = 0;
40+
#pragma omp parallel reduction(+ : counter) default(none) num_threads(num_threads)
41+
{
42+
counter++;
43+
}
4244

4345
GetOutput() /= counter;
4446
return GetOutput() > 0;

0 commit comments

Comments
 (0)