Skip to content

Commit

Permalink
Merge Pull Request trilinos#11946 from trilinos/Trilinos/csiefer-1338338
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Teuchos: Automatically enabling Tecuhos_ENABLE_THREAD_SAFE if you have Kokkos THREADS or OPENMP for the host
PR Author: csiefer2
  • Loading branch information
trilinos-autotester authored Jun 7, 2023
2 parents 2ce5686 + 21e643d commit ea7ea22
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
4 changes: 0 additions & 4 deletions packages/kokkos-kernels/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Adding source directory to the build
LIST(APPEND KK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/common/src)
LIST(APPEND KK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/common/unit_test)

# Adding unit-tests
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/common)
KOKKOSKERNELS_INCLUDE_DIRECTORIES(REQUIRED_DURING_INSTALLATION_TESTING ${CMAKE_CURRENT_SOURCE_DIR}/common)
22 changes: 21 additions & 1 deletion packages/teuchos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,29 @@ IF (DEFINED BUILD_SHARED_LIBS)
ENDIF ()
ENDIF ()


# As per the discussion in #11921, we explicitly enable thread safe RCPs,
# if Kokkos has a host thread-parallel backend
SET(Teuchos_ENABLE_THREAD_SAFE_Default ${Trilinos_ENABLE_THREAD_SAFE})
IF(DEFINED ${PROJECT_NAME}_ENABLE_Kokkos AND ${PROJECT_NAME}_ENABLE_Kokkos)
IF( (DEFINED Kokkos_ENABLE_THREADS AND Kokkos_ENABLE_THREADS) OR
(DEFINED Kokkos_ENABLE_OPENMP AND Kokkos_ENABLE_OPENMP) )
IF (NOT ${PACKAGE_NAME}_ENABLE_THREAD_SAFE)
MESSAGE(WARNING "A Kokkos host thread-parallel backend is enabled, requiring Trilinos to enable thread-safe RCP classes. You can do this manually by specifying Teuchos_ENABLE_THREAD_SAFE=ON")
SET(Teuchos_ENABLE_THREAD_SAFE_Default ON)
ENDIF()
ENDIF()
ENDIF()

TRIBITS_ADD_OPTION_AND_DEFINE(
${PACKAGE_NAME}_ENABLE_THREAD_SAFE
HAVE_TEUCHOS_THREAD_SAFE
"Enable thread safe code for RCP classes."
${Trilinos_ENABLE_THREAD_SAFE}
${Teuchos_ENABLE_THREAD_SAFE_Default}
)



ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_THREAD_SAFE)
ASSERT_DEFINED(${PACKAGE_NAME}Core_ENABLE_Pthread)
COMBINED_OPTION(
Expand All @@ -270,6 +286,10 @@ COMBINED_OPTION(
"Enable thread safe unit tests for ${PACKAGE_NAME} Memory Management classes."
)





TRIBITS_ADD_OPTION_AND_DEFINE(
${PACKAGE_NAME}_ENABLE_ABC
HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void share_arrayview_to_threads(ArrayView<int> shared_arrayview,
++cycle;
}
}
catch (DanglingReferenceError) {
catch (DanglingReferenceError&) {
// loop ends - we got the dangling reference
index_tracker.danglingReference = cycle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ static void do_read_operations_on_array(RCP<arrayType> shared_array,
}
}
}
catch (DanglingReferenceError) {
catch (DanglingReferenceError&) {
// If test throws a dangling reference error, record the cycle it occurred.
index_tracker.danglingReference = cycle;
}
catch (RangeError) {
catch (RangeError&) {
// If tests throws a range error, record the cycle it occurred.
index_tracker.outOfRangeError = cycle;
}
catch (std::out_of_range) {
catch (std::out_of_range&) {
// We could also get std::out_of_range
// Note that here were are counting Trilinos RangeError and STL
// std::out_of_range as all the same - they both happen since the bad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void share_ptr_to_threads(Ptr<int> shared_ptr, int theTestValue,
++cycle;
}
}
catch(DanglingReferenceError) {
catch(DanglingReferenceError&) {
// we got the dangling error as expected
index_tracker.danglingReference = cycle;
}
Expand Down

0 comments on commit ea7ea22

Please sign in to comment.