diff --git a/CMakeLists.txt b/CMakeLists.txt index 028a44b8bd..b8cda33ba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,9 +90,8 @@ if(openmp) # Requires CMake 3.1+ find_package(OpenMP) if(OPENMP_FOUND) - list(APPEND f90flags ${OpenMP_Fortran_FLAGS}) list(APPEND cxxflags ${OpenMP_CXX_FLAGS}) - list(APPEND ldflags ${OpenMP_Fortran_FLAGS}) + list(APPEND ldflags ${OpenMP_CXX_FLAGS}) endif() endif() @@ -422,7 +421,7 @@ add_library(libopenmc SHARED set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc - LINKER_LANGUAGE Fortran) + LINKER_LANGUAGE CXX) target_include_directories(libopenmc PUBLIC include diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index 7767110c27..a4f68bcbef 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -114,11 +114,15 @@ extern std::vector active_surface_tallies; } // namespace model -// Threadprivate variables -extern "C" double global_tally_absorption; -extern "C" double global_tally_collision; -extern "C" double global_tally_tracklength; -extern "C" double global_tally_leakage; +// It is possible to protect accumulate operations on global tallies by using an +// atomic update. However, when multiple threads accumulate to the same global +// tally, it can cause a higher cache miss rate due to invalidation. Thus, we +// use threadprivate variables to accumulate global tallies and then reduce at +// the end of a generation. +extern double global_tally_absorption; +extern double global_tally_collision; +extern double global_tally_tracklength; +extern double global_tally_leakage; #pragma omp threadprivate(global_tally_absorption, global_tally_collision, \ global_tally_tracklength, global_tally_leakage) diff --git a/src/tallies/tally_header.F90 b/src/tallies/tally_header.F90 index f5e2c566de..f61c99a98f 100644 --- a/src/tallies/tally_header.F90 +++ b/src/tallies/tally_header.F90 @@ -155,18 +155,6 @@ module tally_header real(C_DOUBLE), public, allocatable, target :: global_tallies(:,:) - ! It is possible to protect accumulate operations on global tallies by using - ! an atomic update. However, when multiple threads accumulate to the same - ! global tally, it can cause a higher cache miss rate due to - ! invalidation. Thus, we use threadprivate variables to accumulate global - ! tallies and then reduce at the end of a generation. - real(C_DOUBLE), public, bind(C) :: global_tally_collision - real(C_DOUBLE), public, bind(C) :: global_tally_absorption - real(C_DOUBLE), public, bind(C) :: global_tally_tracklength - real(C_DOUBLE), public, bind(C) :: global_tally_leakage -!$omp threadprivate(global_tally_collision, global_tally_absorption, & -!$omp& global_tally_tracklength, global_tally_leakage) - ! Normalization for statistics integer(C_INT32_T), public, bind(C) :: n_realizations = 0 ! # of independent realizations real(C_DOUBLE), public, bind(C) :: total_weight ! total starting particle weight in realization