File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
tasks/example_threads/omp/src Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff 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} " )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments