Skip to content

Commit 6478e11

Browse files
committed
fix reduction
1 parent 076c9a1 commit 6478e11

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

cmake/configure.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ if(UNIX)
6464
-Wold-style-definition \
6565
-Wmissing-prototypes")
6666

67-
if ("${ENABLE_ADDRESS_SANITIZER}"
68-
OR "${ENABLE_UB_SANITIZER}"
69-
OR "${ENABLE_LEAK_SANITIZER}"
70-
OR "${ENABLE_THREAD_SANITIZER}")
71-
set (COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -Wno-cast-align")
72-
endif()
67+
if("${ENABLE_ADDRESS_SANITIZER}"
68+
OR "${ENABLE_UB_SANITIZER}"
69+
OR "${ENABLE_LEAK_SANITIZER}"
70+
OR "${ENABLE_THREAD_SANITIZER}")
71+
set(COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -Wno-cast-align")
72+
endif()
7373

7474
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
7575
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILER_FLAGS}")

tasks/example_threads/omp/src/ops_omp.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ 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+
std::atomic<int> counter{0};
40+
#pragma omp parallel default(none) shared(counter) num_threads(num_threads)
41+
{
42+
counter.fetch_add(1, std::memory_order_relaxed);
43+
}
4244

43-
GetOutput() /= counter;
45+
GetOutput() /= counter.load(std::memory_order_relaxed);
4446
return GetOutput() > 0;
4547
}
4648

0 commit comments

Comments
 (0)