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)
64
64
-Wold-style-definition \
65
65
-Wmissing-prototypes" )
66
66
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 ()
73
73
74
74
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS} " )
75
75
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() {
36
36
const int num_threads = ppc::util::GetNumThreads ();
37
37
GetOutput () *= num_threads;
38
38
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
+ }
42
44
43
- GetOutput () /= counter;
45
+ GetOutput () /= counter. load (std::memory_order_relaxed) ;
44
46
return GetOutput () > 0 ;
45
47
}
46
48
You can’t perform that action at this time.
0 commit comments