Skip to content

Commit

Permalink
Merge pull request #209 from hdante/197-reduction-operation-being-exe…
Browse files Browse the repository at this point in the history
…cuted-in-parallel-with-read-modify-write-operation-in-onesourcegeneratepdf

197 reduction operation being executed in parallel with read modify write operation in onesourcegeneratepdf
  • Loading branch information
johannct authored Sep 17, 2024
2 parents a020312 + 8bc2ba5 commit 09f45c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ else()
add_compile_options("-mno-vzeroupper" "-mavx2" "-floop-unroll-and-jam" )
endif()

# only set these flags if testing presence of race conditions :
# https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual
# on linux/gcc it seems that one needs to run with LD_PRELOAD=/lib/x86_64-linux-gnu/libtsan.so.0 prepended
# and do a `sudo sysctl vm.mmap_rnd_bits=28` prior to running
if(DEFINED ENV{SANITIZE_THREAD})
message(STATUS "Building with thread sanitizing enabled.")
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O2 -fsanitize=thread")
SET(GCC_COVERAGE_LINK_FLAGS "-fsanitize=thread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
endif()

if(DEFINED ENV{INCLUDE_COVERAGE} AND DEFINED ENV{SANITIZE_ADDRESS})
message(FATAL_ERROR "Conflicting build options: INCLUDE_COVERAGE and SANITIZE_ADDRESS")
endif()
Expand All @@ -72,9 +84,9 @@ endif()
if(DEFINED ENV{INCLUDE_COVERAGE})
message(STATUS "Building with code coverage enabled.")
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -coverage -fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-coverage -lgcov")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
SET(GCC_COVERAGE_LINK_FLAGS "-coverage -lgcov -lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
endif()

# Enable the address sanitizer with an environment variable.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/onesource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ void onesource::generatePDF(vector<SED *> &fulllib, const vector<size_t> &va,
// Catch the name of the local thread in the parallelisation
thread_id = omp_get_thread_num();
#pragma omp for schedule(static, 10000) reduction( \
+ : PDFzloc, PDFzqloc, PDFmassloc, PDFSFRloc, PDFsSFRloc, PDFAgeloc) \
nowait
+ : PDFzloc, PDFzqloc, PDFmassloc, PDFSFRloc, PDFsSFRloc, PDFAgeloc, \
PDFLdustloc, PDFcol1loc, PDFcol2loc, PDFmrefloc) nowait
#endif
// Loop over all SEDs, which is parallelized
for (size_t i = 0; i < va.size(); i++) {
Expand Down

0 comments on commit 09f45c1

Please sign in to comment.