We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46a7d58 commit a8f66aaCopy full SHA for a8f66aa
tasks/example_threads/omp/src/ops_omp.cpp
@@ -36,11 +36,13 @@ bool NesterovATestTaskOMP::RunImpl() {
36
const int num_threads = ppc::util::GetNumThreads();
37
GetOutput() *= num_threads;
38
39
- std::atomic<int> counter(0);
40
-#pragma omp parallel default(none) shared(counter) num_threads(ppc::util::GetNumThreads())
41
- counter++;
+ std::atomic<int> counter{0};
+#pragma omp parallel default(none) shared(counter) num_threads(num_threads)
+ {
42
+ counter.fetch_add(1, std::memory_order_relaxed);
43
+ }
44
- GetOutput() /= counter;
45
+ GetOutput() /= counter.load(std::memory_order_relaxed);
46
return GetOutput() > 0;
47
}
48
0 commit comments